#include <bits/stdc++.h>
using namespace std;
const long double pi = 3.14159265358979323846;
long long MOD = 998244353;
const char nl = '\n';
const long long inf = 1e15;
long long power(long long x, long long y) {
  long long z = 1;
  while (y > 0) {
    if (y % 2) z = z * x;
    x = x * x;
    y /= 2;
  }
  return z;
}
long long gcd(long long a, long long b) {
  if (a < b) return gcd(b, a);
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long sq(long long a) {
  long long ans = (1ll * a * a);
  return ans;
}
bool isprime(long long n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (long long i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
long long digitsum(long long x) {
  long long ans = 0;
  while (x > 0) {
    ans += (x % 10);
    x /= 10;
  }
  return ans;
}
set<int> Divisors(int n) {
  set<int> s;
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i) {
        s.insert(i);
      } else {
        s.insert(i);
        s.insert(n / i);
      }
    }
  }
  return s;
}
int n;
int a[100001];
bool solve(int k) {
  if (n / k < 3) return false;
  for (int i = 0; i < k; ++i) {
    bool ok = true;
    for (int j = i; j < n; j += k) {
      ok &= a[j];
    }
    if (ok) return true;
  }
  return false;
}
void solve() {
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i * i <= n; ++i) {
    if (n % i == 0 && (solve(i) || solve(n / i))) {
      cout << "YES\n";
      return;
    }
  }
  cout << "NO\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  long long TC = 1;
  while (TC--) {
    solve();
  }
}
