#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int k = 1; k <= n / 3; k++) {
    if (n % k == 0) {
      for (int p = 0; p < k; p++) {
        int sum = 0;
        for (int v = p; v < n; v += k) {
          if (a[v] == 1) sum++;
        }
        if (sum == n / k) {
          cout << "YES\n";
          return 0;
        }
      }
    }
  }
  cout << "NO\n";
  return 0;
}
