#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 100;
int n, a[maxn];
char s[maxn];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int l = 1, r = n, ans = 0, now = 0;
  while (l <= r) {
    if (a[l] < now && a[r] < now) break;
    if (l == r) {
      if (a[l] > now) s[ans++] = 'L';
      break;
    }
    if (a[l] < a[r] && a[l] > now) {
      s[ans++] = 'L';
      now = a[l];
      l++;
    } else if (a[l] < a[r] && a[r] > now) {
      s[ans++] = 'R';
      now = a[r];
      r--;
    } else if (a[l] > a[r] && a[r] > now) {
      s[ans++] = 'R';
      now = a[r];
      r--;
    } else if (a[l] > a[r] && a[l] > now) {
      s[ans++] = 'L';
      now = a[l];
      l++;
    }
  }
  cout << ans << endl << s << endl;
  return 0;
}
