#include <bits/stdc++.h>
using namespace std;
long long modpow(long long base, long long exp, long long modulus) {
  base %= modulus;
  long long result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
int a[1000006];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; i++) {
    if ((n) % i != 0) continue;
    for (int j = 1; j <= i; j++) {
      int k = j;
      int flag = 0;
      int cnt = 0;
      while (k <= n) {
        if (a[k] == 0) {
          flag = 1;
          break;
        }
        k = k + i;
        cnt++;
      }
      if (k > n) k -= i;
      if (flag == 1) continue;
      if (cnt > 2 && (n - k + j - 1 + 1) == i) {
        printf("YES\n");
        return 0;
      }
    }
  }
  printf("NO\n");
  return 0;
}
