#include <bits/stdc++.h>
using namespace std;
const int maxn = 1234567;
int query(vector<long long> a) {
  int n = a.size();
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      if (n % (i * i) != 0) {
        for (int j = 0; j < n; j += i) {
          long long d = a[j];
          int k = j;
          do {
            a[k] -= d;
            k = (k + n / i) % n;
          } while (k != j);
        }
      }
      vector<vector<long long> > w(i);
      for (int j = 0; j < n; j++) w[j % i].push_back(a[j]);
      bool f = 1;
      for (int j = 0; j < i; j++)
        if (!query(w[j])) {
          f = 0;
          break;
        }
      return f;
    }
  }
  for (int i = 1; i < a.size(); i++)
    if (a[i] != a[0]) return 0;
  return 1;
}
int main() {
  int n;
  string s;
  cin >> n >> s;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) a[i] = s[i] - '0';
  cout << (query(a) ? "YES" : "NO");
  return 0;
}
