#include <bits/stdc++.h>
using namespace std;
int arr[100000];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> arr[i];
  for (int i = 1; n / i >= 3; ++i) {
    if (n % i != 0) continue;
    for (int j = 0; j < i; ++j) {
      int Ok = 0;
      for (int k = j; k < n; k += i) {
        if (arr[k] == 1) ++Ok;
      }
      if (Ok == n / i) {
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  cout << "NO" << endl;
  return 0;
}
