#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = 1e-11;
void fast() { std::ios_base::sync_with_stdio(0); }
int n;
vector<int> arr;
void check(int x) {
  if (n / x < 3) return;
  for (int i = 0; i < x; i++) {
    bool ok = true;
    for (int j = i; j < n; j += x) ok &= arr[j];
    if (ok) {
      puts("YES");
      exit(0);
    }
  }
}
int main() {
  cin >> n;
  arr.resize(n);
  for (int &i : arr) cin >> i;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      check(i);
      check(n / i);
    }
  }
  puts("NO");
  return 0;
}
