#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 2;
int n;
char ar[N];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
  }
  for (int d = 1; d <= n; d++) {
    if (n % d == 0) {
      reverse(ar, ar + d);
    }
  }
  for (int i = 0; i < n; i++) cout << ar[i];
}
