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