#include <bits/stdc++.h>
using namespace std;
string reverse(string s, int i) {
  int l = s.length();
  string temp;
  if (i == l) {
    temp = "";
  } else {
    temp = s.substr(i, l - i);
  }
  int j;
  string s1 = "";
  for (j = i - 1; j >= 0; j--) {
    s1 = s1 + s[j];
  }
  return s1 + temp;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, i;
  cin >> n;
  string s;
  cin >> s;
  for (i = 1; i <= n; i++) {
    if (n % i == 0) {
      s = reverse(s, i);
    }
  }
  cout << s << "\n";
  return 0;
}
