#include <bits/stdc++.h>
const int kN = 100000 + 5;
double a[kN];
int n;
char str[kN];
int main() {
  scanf("%d", &n);
  scanf("%s", str);
  for (int i = 0; i < n; ++i) a[i] = str[i] - '0';
  std::vector<int> div;
  int x = n;
  for (int i = 2; i * i <= x; ++i) {
    while (x % i == 0) x /= i, div.emplace_back(i);
  }
  if (x > 1) div.emplace_back(x);
  for (int p : div) {
    for (int i = 0; i < n / p; ++i) {
      double s = 0;
      for (int j = i; j < n; j += n / p) s += a[j];
      s /= p;
      for (int j = i; j < n; j += n / p) a[j] -= s;
    }
  }
  for (int i = 0; i < n; ++i)
    if (a[i] >= 1e-9 || a[i] <= -1e-9) return puts("NO"), 0;
  puts("YES");
}
