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