Let $A_1A_2...A_n$ be a regular polygon ($n > 4$), $T$ be the common point of $A_1A_2$ and $A_{n-1}A_n$ and $M$ be a point in the interior of the triangle $A_1A_nT$. Show that the equality $$\sum_{i=1}^{n-1} \frac{\sin^2 \left(\angle A_iMA_{i+1}\right)}{d(M,A_iA_{i+1}}=\frac{\sin^2 \left(\angle A_1MA_n\right)}{d(M,A_1A_n} $$holds if and only if $M$ belongs to the circumcircle of the polygon.