#include <bits/stdc++.h>
using namespace std;
char a[105];
int main() {
  int n;
  while (cin >> n) {
    cin >> a;
    for (int i = 1; i <= n; i++) {
      if (n % i == 0) reverse(a, a + i);
    }
    cout << a;
  }
}
