#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> v(n);
  for (auto &i : v) {
    cin >> i;
  }
  auto check = [&n, &v](int x) {
    if (n / x < 3) return;
    for (int i = 0; i < x; i++) {
      int ch = 1;
      for (int j = i; j < n; j += x) {
        ch &= v[j];
      }
      if (ch == 1) cout << "YES", exit(0);
    }
  };
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      check(i);
      check(n / i);
    }
  }
  cout << "NO";
  return 0;
}
