#include <bits/stdc++.h>
using namespace std;
int n;
string s;
vector<int> v;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> s;
  s = '*' + s;
  for (int i = 1; i * i <= n; i++)
    if (n % i == 0) {
      v.push_back(i);
      if (i != n / i) v.push_back(n / i);
    }
  sort(v.begin(), v.end());
  for (int x : v) reverse(s.begin() + 1, s.begin() + 1 + x);
  s.erase(0, 1);
  cout << s;
  return 0;
}
