#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
template <class T>
T ABS(const T& x) {
  return x > 0 ? x : -x;
}
long long int gcd(long long int n1, long long int n2) {
  return n2 == 0 ? ABS(n1) : gcd(n2, n1 % n2);
}
long long int lcm(long long int n1, long long int n2) {
  return n1 == 0 && n2 == 0 ? 0 : ABS(n1 * n2) / gcd(n1, n2);
}
long long int ceil2(long long int a, long long int b) {
  return (a + b - 1) / b;
}
int n;
void divisors(vector<int>& d) {
  vector<int> v;
  for (int i = 1; i <= sqrt(n); ++i) {
    if (n % i == 0) {
      if (n / i == i) {
        d.push_back(i);
      } else {
        d.push_back(i);
        v.push_back(n / i);
      }
    }
  }
  for (int i = v.size() - 1; i >= 0; --i) {
    d.push_back(v[i]);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  int arr[n];
  for (int i = 0; i < (n); ++i) {
    cin >> arr[i];
  }
  vector<int> d;
  divisors(d);
  bool v[n];
  for (int i = d.size() - 1; i >= 0; --i) {
    int size = n / d[i];
    if (size < 3) continue;
    memset(v, false, sizeof(v));
    int k = d[i], cnt = 0;
    for (int l = 0; l < n; ++l) {
      int prev = (l - k + n) % n, next = (l + k) % n;
      if (arr[l] && arr[prev] && arr[next]) {
        v[l] = true;
        cnt++;
      } else {
        v[l] = false;
      }
    }
    if (cnt >= size) {
      cout << "YES\n";
      return 0;
    }
  }
  cout << "NO\n";
  return 0;
}
