#include <bits/stdc++.h>
using namespace std;
long long const M = 1000000007;
double const pi = acos(-1);
long long const inf = 2e18;
long long const N = 200001;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long i, j, t, n, k;
  cin >> n;
  vector<long long> a(n);
  bool ok = false;
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      long long counter = n / i, mxi = 0;
      vector<long long> dp(n, 0);
      if (i != 2) {
        for (j = 0; j < n; j++) {
          if (a[j] == 1) {
            dp[j] = 1;
            if (j - counter >= 0) dp[j] += dp[j - counter];
          }
          mxi = max(mxi, dp[j]);
        }
      }
      if (mxi >= i) ok = true;
      counter = i, mxi = 0;
      for (j = 0; j < n; j++) dp[i] = 0;
      for (j = 0; j < n; j++) {
        if (a[j] == 1) {
          dp[j] = 1;
          if (j - counter >= 0) dp[j] += dp[j - counter];
        }
        mxi = max(mxi, dp[j]);
      }
      if (mxi >= (n / i) && (n / i != 2)) ok = true;
    }
    if (ok) break;
  }
  long long cnt = 0;
  for (i = 0; i < n; i++)
    if (a[i] == 1) cnt++;
  if (cnt == n) ok = true;
  if (ok)
    cout << "YES"
         << "\n";
  else
    cout << "NO"
         << "\n";
  return 0;
}
