#include <bits/stdc++.h>
using namespace std;
const long oo = int(1e9);
const long N = int(1e5) + 5;
long n, a[N];
bool ok(long first) {
  for (long i = 1; i <= first; i++) {
    bool ok = 1;
    for (long j = i; j <= n; j += first)
      if (a[j] != 1) ok = 0;
    if (ok) return 1;
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  cin >> n;
  for (long i = 1; i <= n; i++) cin >> a[i];
  for (long i = 1; i <= n; i++)
    if (n % i == 0) {
      if (ok(i) && n / i >= 3) {
        cout << "YES\n";
        return 0;
      }
      if (ok(n / i) && i >= 3) {
        cout << "YES\n";
        return 0;
      }
    }
  cout << "NO\n";
}
