#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f2f1f0f;
const long long LINF = 1ll * INF * INF;
int N;
vector<int> Nr;
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    int x;
    scanf("%1d", &x);
    Nr.push_back(x);
  }
  vector<int> Ps;
  int tN = N;
  for (int p = 2; p * p <= tN; p++) {
    if (tN % p != 0) continue;
    while (tN % p == 0) tN /= p;
    Ps.push_back(p);
  }
  if (tN != 1) Ps.push_back(tN);
  vector<int> temp = Nr;
  for (int p : Ps) {
    int mn = N / p;
    for (int i = 0; i < N; i++) temp[(i + mn) % N] = Nr[i];
    for (int i = 0; i < N; i++) temp[i] -= Nr[i];
    Nr = temp;
  }
  bool isDiv = true;
  for (int i = 0; i < N; i++)
    if (Nr[i]) isDiv = false;
  puts(isDiv ? "YES" : "NO");
  return 0;
}
