#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 5;
vector<int> f;
char s[maxn];
long long a[maxn];
int main() {
  int n, m, i, j, x;
  long long u;
  scanf("%d", &n);
  for (i = 2, x = n; i * i <= x; i++) {
    if (x % i == 0) {
      f.push_back(i);
      while (x % i == 0) x /= i;
    }
  }
  if (x > 1) f.push_back(x);
  scanf("%s", s);
  for (i = 0; i < n; i++) a[i] = s[i] - '0';
  for (auto e : f) {
    m = n / e;
    for (i = 0; i < m; i++) {
      for (j = i + m, u = a[i + m] - a[i]; j < n; j += m, u = a[j] - u)
        swap(u, a[j]);
      a[i] += u;
    }
  }
  bool vis = 1;
  for (i = 1; i < n; i++) vis &= (a[i] == a[0]);
  if (vis)
    puts("YES");
  else
    puts("NO");
  return 0;
}
