#include <bits/stdc++.h>
using namespace std;
long long n, t = 0;
string a = "";
string per(string h, long long x) {
  string c = "";
  string g = h.substr(x, h.length() - x);
  for (long long o = x - 1; o >= 0; o--) {
    c += h[o];
  }
  c = c + g;
  return c;
}
int main() {
  cin >> n;
  cin >> a;
  for (long long i = 1; i <= n; i++) {
    if ((a.length() % i) == 0) {
      a = per(a, i);
    }
  }
  cout << a << endl;
}
