#include <bits/stdc++.h>
const int MAX_SIZE = 100 + 10;
int nbChar;
char tab[MAX_SIZE];
void reverse(int debut, int fin) {
  fin--;
  while (debut < fin) {
    std::swap(tab[debut], tab[fin]);
    debut++;
    fin--;
  }
}
int main() {
  scanf("%d%s", &nbChar, tab);
  for (int i = 1; i <= nbChar; i++)
    if (nbChar % i == 0) reverse(0, i);
  for (int i = 0; i < nbChar; i++) printf("%c", tab[i]);
}
