#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = INT_MAX;
const vector<vector<int> > adj4({{0, 1}, {0, -1}, {1, 0}, {-1, 0}});
const vector<vector<int> > adj8(
    {{0, 1}, {0, -1}, {1, 0}, {-1, 0}, {-1, -1}, {1, -1}, {-1, 1}, {1, 1}});
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int powMod(int a, int b, int mod) {
  int n = 1;
  int p = a;
  while (b > 0) {
    if (b % 2 == 1) {
      n *= p;
      n %= mod;
    }
    p *= p;
    p %= mod;
    b /= 2;
  }
  return n;
}
int modularInverse(int a, int mod) { return powMod(a, mod - 2, mod); }
stringstream sss;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  sss << R"(
6
1 0 1 1 1 0
    )";
  int n;
  cin >> n;
  vector<bool> arr(n);
  for (int i = 0; i < (n); ++i) {
    int a;
    cin >> a;
    arr[i] = a;
  }
  int sz = n;
  vector<bool> p(sz, false);
  for (int i = (1); i < (sz); ++i) {
    if (true) {
      ;
      if (n % i != 0 || n < i * 3) continue;
      vector<int> cnt(i, 0);
      for (int k = 0; k < (n); ++k) {
        if (arr[k]) {
          ++cnt[k % i];
        }
      };
      for (int k = 0; k < (i); ++k) {
        if (cnt[k] == n / i) {
          cout << ("YES") << endl;
          return 0;
        }
      }
    }
  }
  cout << ("NO") << endl;
  return 0;
}
