Codeforces Beta Round 65 (Div. 2)
C
Round Table Knights
Codeforces
1600
原题
← BD →
翻译中…

There are $*n*$ knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.

翻译中…

Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights in a good mood should be located. Otherwise, the next month will bring misfortunes.

翻译中…

A convex polygon is regular if all its sides have same length and all his angles are equal. In this problem we consider only regular polygons with at least 3 vertices, i. e. only nondegenerated.

翻译中…

On a picture below some examples of such polygons are present. Green points mean knights in a good mood. Red points mean ones in a bad mood.

翻译中…

image

翻译中…

King Arthur knows the knights' moods. Help him find out if the next month will be fortunate or not.

翻译中…

Input

翻译中…

The first line contains number $*n*$, which is the number of knights at the round table ($3 ≤ *n* ≤ 10^{5}$). The second line contains space-separated moods of all the $*n*$ knights in the order of passing them around the table. "1" means that the knight is in a good mood an "0" means that he is in a bad mood.

翻译中…

Output

翻译中…

Print "YES" without the quotes if the following month will turn out to be lucky. Otherwise, print "NO".

翻译中…

样例

Input #1
3
1 1 1
Output #1
YES
InputCopy OutputCopy
Input #2
6
1 0 1 1 1 0
Output #2
YES
InputCopy OutputCopy
Input #3
6
1 0 0 1 0 1
Output #3
NO
InputCopy OutputCopy
题目信息
题号
71C
时间限制
0.5 s
内存限制
256 MB
标签
动态规划
数学
数论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。