#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, r = 0;
  cin >> n;
  string s;
  cin >> s;
  int a[60];
  for (int i = n; i >= 1; i--) {
    if (n % i == 0) {
      a[r] = i;
      r++;
    }
  }
  for (int i = r - 1; i >= 0; i--) reverse(s.begin(), s.begin() + a[i]);
  cout << s << endl;
}
