#include <bits/stdc++.h>
using namespace std;
const int OO = (int)1e9;
int dx[8] = {0, 0, -1, 1, 1, 1, -1, -1};
int dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};
long long n, z, cnt, x, y;
vector<long long> divisors;
vector<int> a;
vector<long long> generate_divisors(long long n) {
  vector<long long> v;
  long long i;
  for (i = 1; i * i < n; ++i)
    if (n % i == 0) v.push_back(i), v.push_back(n / i);
  if (i * i == n) v.push_back(i);
  return v;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  divisors = generate_divisors(n);
  bool e = 1;
  for (int i = 0; i < ((long long)((divisors).size())) && e; i++) {
    x = divisors[i];
    y = 0;
    while (e && y < x) {
      cnt = 0;
      for (int j = y; j < n; j += x) {
        if (a[j] == 1) {
          cnt++;
        } else {
          break;
        }
      }
      if ((cnt == (n / x)) && (cnt >= 3)) {
        e = 0;
      }
      y++;
    }
  }
  if (!e) {
    cout << "YES"
         << "\n";
  } else {
    cout << "NO"
         << "\n";
  }
  return 0;
}
