#include <bits/stdc++.h>
using namespace std;
bool a[100005];
int n;
bool check(int v) {
  if (v == 2 || v == 1) return 0;
  int i = 0, x = n / v;
  int ct = n / v;
  while (ct--) {
    int sum = 0;
    for (int j = i; j < n; j += x) sum += a[j];
    if (sum == v) return 1;
    i++;
  }
  return 0;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      if (check(i) || check(n / i)) {
        cout << "YES";
        return 0;
      }
    }
  }
  cout << "NO";
  return 0;
}
