#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6;
int n;
char s[maxn];
int arr[maxn];
int k = 1;
void Reverse(char *s, int n) {
  for (int i = 0, j = n - 1; i < j; i++, j--) {
    char c = s[i];
    s[i] = s[j];
    s[j] = c;
  }
}
int main() {
  cin >> n >> s;
  for (int i = 1; i <= n; i++) {
    if (n % i == 0) {
      arr[k] = i;
      k++;
    }
  }
  k--;
  for (int i = 1; i <= n; i++) {
    Reverse(s, arr[i]);
  }
  cout << s << endl;
  return 0;
}
