#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007, mod2 = 998244353, inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
int a[maxn];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  string ans = "";
  int l = 1, r = n, last = 0, cnt = 0;
  for (int i = 1; i <= n; ++i) {
    if (a[l] > last && a[r] > last) {
      if (a[l] < a[r]) {
        ans += "L";
        last = a[l++];
      } else {
        ans += "R";
        last = a[r--];
      }
      ++cnt;
    } else if (a[l] > last) {
      ans += "L";
      last = a[l++];
      ++cnt;
    } else if (a[r] > last) {
      ans += "R";
      last = a[r--];
      ++cnt;
    } else
      break;
  }
  cout << cnt << '\n' << ans << endl;
  return 0;
}
