#include using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { cin.tie(nullptr)->sync_with_stdio(false); int n; cin >> n; vector a(n); rep(i, n) cin >> a[i]; int pos = 0; rep(i, n) if (a[i] == n - 1) pos = i; string ans = ""; const auto Swap = [&]() { ans += 'S'; swap(a[0], a[1]); }; const auto Rotate = [&]() { ans += 'R'; pos = (pos - 1 + n) % n; rotate(a.begin(), a.begin() + 1, a.end()); }; for (int x = n - 2; x >= 0; --x) { while (a[0] != x) Rotate(); while (pos >= 2) Swap(), Rotate(); assert(a[0] == x); assert(a[0] + 1 == a[1]); assert(pos == 1); pos--; Debug(x, a, pos, ans); } assert(is_sorted(a.begin(), a.end())); cout << ans << '\n'; return 0; }