#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = acos(-1);
template <class T>
T sqr(T x) {
  return x * x;
}
template <class T>
T abs(T x) {
  return x < 0 ? -x : x;
}
vector<int> GetP(int n) {
  vector<int> res;
  for (int i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      res.push_back(i);
      while (n % i == 0) {
        n /= i;
      }
    }
  }
  if (n > 1) {
    res.push_back(n);
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    a[i] = s[i] - '0';
  }
  vector<int> p = GetP(n);
  int num = ((int)(p).size());
  int mult = 1;
  for (int i = 0; i < num; ++i) {
    mult *= p[i];
  }
  vector<bool> good(mult, true);
  vector<vector<int>> proj(num, vector<int>(mult));
  for (int i = 0; i < num; ++i) {
    int add = mult / p[i];
    for (int x = 0; x < mult; x += p[i]) {
      good[x] = false;
      int y = x;
      for (int j = 0; j < p[i]; ++j) {
        proj[i][y] = x;
        y += add;
        if (y >= mult) {
          y -= mult;
        }
      }
    }
  }
  int d = n / mult;
  vector<int> cur_check(mult);
  vector<int> sum(mult);
  bool key = true;
  for (int r = 0; r < d; ++r) {
    for (int i = 0; i < mult; ++i) {
      cur_check[i] = a[r + i * d];
    }
    for (int i = 0; i < mult; ++i) {
      sum[i] = cur_check[i];
    }
    for (int i = 0; i < num; ++i) {
      for (int j = 0; j < mult; ++j) {
        if (proj[i][j] != j) {
          sum[j] -= sum[proj[i][j]];
        }
      }
    }
    for (int i = 0; i < mult; ++i) {
      if (good[i] && sum[i] != 0) {
        key = false;
        break;
      }
    }
    if (!key) {
      break;
    }
  }
  cout << (key ? "YES" : "NO") << "\n";
  return 0;
}
