#include <bits/stdc++.h>
using namespace std;
long long a[200005];
void solve() {
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long l = 0, r = n - 1;
  long long cur = 0, cnt = 0;
  string ans = "";
  while (r >= l && max(a[l], a[r]) > cur) {
    if (min(a[l], a[r]) > cur) {
      if (a[l] < a[r]) {
        cur = a[l];
        ans += 'L';
        l++;
      } else {
        cur = a[r];
        ans += 'R';
        r--;
      }
    } else {
      if (a[l] < a[r]) {
        cur = a[r];
        ans += 'R';
        r--;
      } else {
        cur = a[l];
        ans += 'L';
        l++;
      }
    }
    cnt++;
  }
  cout << cnt << '\n' << ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
