#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200015;
const int MOD = 1000000007;
int a[MAXN];
bool F(int len, int num) {
  bool flag;
  int pres;
  for (int i = 0; i <= num - 1; i++) {
    flag = true;
    pres = i;
    for (int j = 0; j <= len - 1; j++) {
      if (a[pres] == 0) flag = false;
      pres += num;
    }
    if (flag == true) return flag;
  }
  return false;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i <= n - 1; i++) scanf("%d", &a[i]);
  bool ok = false;
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (i >= 3) ok = ok | F(i, n / i);
      if (i != sqrt(n) && n / i >= 3) ok = ok | F(n / i, i);
    }
  }
  if (ok)
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}
