#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; if(!(cin >> n)) return 0; vector P(n); for (int i = 0; i < n; ++i) cin >> P[i]; string ops; ops.reserve(20000); auto doS = [&](){ swap(P[0], P[1]); ops.push_back('S'); }; auto doR = [&](){ rotate(P.begin(), P.begin()+1, P.end()); // 左回転(Pi <- P(i+1)) ops.push_back('R'); }; // リング上のバブルソート:各ステップで (必要ならS) -> R を行う // n*(n-1) 回で循環的昇順(k,k+1,...,n-1,0,1,...,k-1)になる for (int t = 0; t < n*(n-1); ++t) { // ただし (n-1,0) の並びは崩さないようにする if (P[0] > P[1] && !(P[0] == n-1 && P[1] == 0)) doS(); doR(); } // 先頭を 0 にそろえる int pos0 = -1; for (int i = 0; i < n; ++i) if (P[i] == 0) { pos0 = i; break; } for (int i = 0; i < pos0; ++i) doR(); cout << ops << '\n'; return 0; }