#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int arr[150];
  int l = 0;
  for (int i = 1; i <= n; i++) {
    if (n % i == 0) {
      arr[l] = i;
      l++;
    }
  }
  for (int i = 0; i < l; i++) {
    int st = 0, en = arr[i] - 1;
    for (int j = 0; j < arr[i] / 2; j++) {
      char c = s[st];
      s[st] = s[en];
      s[en] = c;
      st++;
      en--;
    }
  }
  cout << s;
  return 0;
}
