#include <bits/stdc++.h>
using namespace std;
const int N = 100010, M = 600010;
int cp, p[30], c[30], pc[30];
int a[M], b[M];
char s[N];
void decompose(int x) {
  int i;
  for (i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      cp++;
      p[cp] = i;
      pc[cp] = 1;
      while (x % i == 0) {
        x /= i;
        c[cp]++;
        pc[cp] *= i;
      }
    }
  }
  if (x > 1) {
    cp++;
    p[cp] = x;
    c[cp] = 1;
    pc[cp] = x;
  }
}
int main() {
  int i, j, k;
  int n, m;
  long double x;
  scanf("%d", &n);
  decompose(n);
  m = n - 1;
  scanf("%s", s + 1);
  for (i = 0; i <= n - 1; i++) a[i] = s[i + 1] - '0';
  for (i = 1; i <= cp; i++) {
    for (j = 0; j <= m; j++) b[j] = 0;
    for (j = 0; j <= m; j++) {
      b[j] -= a[j];
      b[j + n / p[i]] += a[j];
    }
    m += n / p[i];
    for (j = 0; j <= m; j++) a[j] = b[j];
  }
  for (i = m; i >= n; i--) {
    a[i - n] += a[i];
    a[i] = 0;
  }
  for (i = 0; i <= m; i++)
    if (a[i] != 0) {
      printf("NO\n");
      return 0;
    }
  printf("YES\n");
}
