#include <bits/stdc++.h>
using namespace std;
long double PI = 3.141592653589793238462643;
long double eps = 0.000000000001;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int32_t main() {
  long long n;
  cin >> n;
  string s;
  cin >> s;
  vector<pair<long double, long double> > p;
  pair<long double, long double> vect = make_pair(1, 0);
  p.push_back(make_pair(0, 0));
  for (long long i = 0; i < n - 1; i++) {
    pair<long double, long double> pp = p.back();
    p.push_back(make_pair(pp.first + vect.first, pp.second + vect.second));
    long double angle = 2 * PI * ((long double)(i + 1) / (long double)(n));
    vect.first = cos(angle);
    vect.second = sin(angle);
  }
  bool zer = true;
  for (long long i = 0; i < n; i++) {
    if (s[i] != '0') zer = false;
  }
  if (zer) {
    cout << "YES" << endl;
    return 0;
  }
  long double xr = 0, yr = 0;
  long long sm = 0;
  for (long long i = 0; i < n; i++) {
    long long symb = s[i] - '0';
    sm += symb;
    xr += (long double)symb * p[i].first;
    yr += (long double)symb * p[i].second;
  }
  xr /= (long double)sm;
  yr /= (long double)sm;
  string ss;
  for (long long i = 0; i < n; i++) {
    ss.push_back('0');
  }
  for (long long it = 0; it < 100; it++) {
    long long m;
    while (true) {
      m = (((long long)rand() * (long long)rand()) % n) * rand();
      if (gcd(n, m) == 1) break;
    }
    for (long long j = 0; j < n; j++) {
      long long nc = (j * m) % n;
      ss[nc] = s[j];
    }
    long double xd = 0, yd = 0;
    for (long long i = 0; i < n; i++) {
      long long symb = ss[i] - '0';
      xd += (long double)symb * p[i].first;
      yd += (long double)symb * p[i].second;
    }
    xd /= (long double)sm;
    yd /= (long double)sm;
    if (abs(xd - xr) >= eps || abs(yd - yr) >= eps) {
      cout << "NO" << endl;
      return 0;
    }
  }
  for (long long it = 0; it < 100; it++) {
    for (long long j = 0; j < n; j++) {
      long long nc = (j + it) % n;
      ss[nc] = s[j];
    }
    long double xd = 0, yd = 0;
    for (long long i = 0; i < n; i++) {
      long long symb = ss[i] - '0';
      xd += (long double)symb * p[i].first;
      yd += (long double)symb * p[i].second;
    }
    xd /= (long double)sm;
    yd /= (long double)sm;
    if (abs(xd - xr) >= eps || abs(yd - yr) >= eps) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}
