#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const int M = 1e9 + 7;
const int MOD = 998244353;
const double PI = 3.141592653589793238460;
long long int power(long long int a, long long int b) {
  long long int res = 1;
  if (a == 0) return 0;
  if (a == 1) return 1;
  for (; b > 0; b >>= 1) {
    if (b & 1) res = (res * a);
    if (res > MOD) res %= MOD;
    a = (a * a);
    if (a > MOD) a = a % MOD;
  }
  return res;
}
bool isPrime[10001];
vector<int> prime;
void seive() {
  isPrime[0] = isPrime[1] = 1;
  for (int i = 2; i * i <= 10000; i++) {
    if (!isPrime[i])
      for (int j = i * i; j <= 10000; j += i) {
        isPrime[j] = 1;
      }
  }
  for (int i = 2; i <= 10000; i++)
    if (!isPrime[i]) prime.push_back(i);
}
int main() {
  int n;
  cin >> n;
  int arr[n];
  int flag = 1;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    if (!arr[i]) flag = 0;
  }
  if (flag) {
    cout << "YES";
    return 0;
  }
  int diff = 2;
  for (int diff = 2; diff <= n / 3 + 1; diff++) {
    if (n % diff != 0) continue;
    for (int j = 0; j < diff; j++) {
      int cnt = 0, last;
      flag = 1;
      for (int i = j; i < n; i += diff) {
        if (arr[i] == 1)
          cnt++, last = i;
        else {
          flag = 0;
          break;
        }
      }
      if (n - last + j != diff) flag = 0;
      if (flag && cnt > 2) {
        cout << "YES";
        return 0;
      } else if (flag) {
        cout << "NO";
        return 0;
      }
    }
  }
  cout << "NO";
}
