#include using namespace std; using ll = long long; bool chmin(auto &a, auto b) { return a > b ? a = b, true : false; } bool chmax(auto &a, auto b) { return a < b ? a = b, true : false; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector P(N); for (auto &e : P) cin >> e; string ans; auto SWAP = [&] () -> void { ans.push_back('S'); swap(P[0], P[1]); }; auto ROTATE = [&] () -> void { ans.push_back('R'); vector Q(N); for (int i = 0; i < N; i++) { Q[i] = P[(i + 1) % N]; } P = Q; }; while (P[N - 1] != N - 1) ROTATE(); for (int i = N - 2; i >= 0; i--) { if (P[i] == i) continue; while (P[0] != i) ROTATE(); while (P[1] != i + 1) { SWAP(); ROTATE(); } while (P[i] != i) ROTATE(); } // for (int i = 0; i < N; i++) cout << P[i] << " \n"[i + 1 == N]; cout << ans << endl; }