#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int seive[N];
void pre() {
  fill(seive + 2, seive + N, 1);
  for (int i = 2; i < N; i++) {
    if (seive[i]) {
      for (int j = 2; j * i <= N; j++) {
        seive[i * j] = 0;
      }
    }
  }
}
int n, a[N];
void check(int i) {
  if (n / i < 3) return;
  for (int j = 0; j < i; j++) {
    bool q = 1;
    for (int k = j; k < n; k += i) {
      q &= a[k];
    }
    if (q) {
      cout << "YES\n";
      exit(0);
    }
  }
}
int32_t main() {
  cin >> n;
  for (__typeof(n) i = 0; i < n; ++i) cin >> a[i];
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      check(i);
      check(n / i);
    }
  }
  cout << "NO";
}
