#include <bits/stdc++.h>
using namespace std;
int n, i, a[100003], j, k;
int main() {
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  for (i = 1; i <= n / 3; i++)
    if (n % i == 0) {
      for (j = 0; j < i; j++) {
        int z = 1;
        for (k = j; k < n; k += i) z &= a[k];
        if (z) return cout << "YES", 0;
      }
    }
  cout << "NO";
}
