#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int T = 1;
  while (T--) {
    long long int n, i, t, j, k;
    cin >> n;
    long long int N = n;
    bool mood[n + 5];
    bool chh = true;
    for (i = 0; i < n; i++) {
      cin >> mood[i];
      chh = chh && mood[i];
    }
    if (chh) {
      cout << "YES";
      return 0;
    }
    vector<long long int> ans;
    for (i = 1; i * i < n; i++) {
      if (n % i == 0) {
        long long int ttt = n / i;
        ans.emplace_back(i);
        if (i != ttt) ans.emplace_back(ttt);
      }
    }
    n = N;
    long long int skip;
    skip = 1;
    sort((ans).begin(), (ans).end());
    for (i = ans.size() - 1; i >= 0; i--) {
      if (n / ans[i] >= 3) {
        skip = ans[i];
        break;
      }
    }
    if (skip == 1) {
      cout << "NO";
      return 0;
    }
    for (k = 0; k < ans.size(); k++) {
      skip = ans[k];
      if (n / skip < 3) continue;
      for (i = 0; i < skip; i++) {
        bool hoga = true;
        for (j = i; j < n; j += (skip)) {
          if (mood[j] == false) {
            hoga = false;
            break;
          }
        }
        if (hoga == true) {
          cout << "YES";
          return 0;
        }
      }
    }
    cout << "NO";
  }
  return 0;
}
