#include <bits/stdc++.h>
using namespace std;
double mod(double a) { return (a > 0 ? a : (-a)); }
unsigned long max(unsigned long int a, unsigned long int b) {
  return (a) > (b) ? (a) : (b);
}
bool sortbyff(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.first < b.first);
}
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
int main() {
  long n, k, l, r, i, iprev, j, flag = 0, e, t, sum = 0, ans = 0, a, b, c,
                                nine = 1000000007 - 7;
  double avg = 0.0, eps = 0.000001;
  cin >> n;
  bool p[n];
  for (i = 0; i < n; i++) cin >> p[i];
  for (i = 1; i * i <= n; i++) {
    long bi = n % i == 0 ? n / i : 0;
    if (bi) {
      for (j = 0; j < i; j++) {
        flag = 0;
        c = 0;
        for (k = j; k < n; k += i) {
          c++;
          if (!p[k]) flag = 1;
        }
        if (!flag && c == bi && bi > 2) {
          cout << "YES";
          return 0;
        }
      }
      for (j = 0; j < bi; j++) {
        flag = 0;
        c = 0;
        for (k = j; k < n; k += bi) {
          c++;
          if (!p[k]) flag = 1;
        }
        if (!flag && c == i && i > 2) {
          cout << "YES";
          return 0;
        }
      }
    }
  }
  cout << "NO";
  return 0;
}
