#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 5;
bool m[maxn];
int a[maxn];
int main() {
  int n, sum = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum += a[i];
  }
  if (n == sum) {
    cout << "YES" << endl;
    return 0;
  }
  bool flag = false;
  for (int t = 3; t <= n; t++)
    if (n % t == 0) {
      memset(m, 0, sizeof(m));
      for (int i = 1; i <= n / t; i++) {
        if (a[i] == 1) {
          for (int j = i; j <= n; j += n / t)
            if (a[i] + a[j] != 2) m[i] = 1;
        } else
          m[i] = 1;
      }
      int cnt = 0;
      for (int i = 1; i <= n / t; i++)
        if (!m[i]) cnt++;
      if (cnt) flag = true;
    }
  if (flag)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
