#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, l, r, top, arr[200005];
  string s;
  cin >> n;
  for (i = 0; i < n; i++) cin >> arr[i];
  l = 0, r = n - 1;
  top = 0;
  while (l <= r) {
    if (arr[l] < arr[r]) {
      if (top < arr[l]) {
        top = arr[l];
        l++;
        s += 'L';
      } else {
        if (top < arr[r]) {
          top = arr[r];
          r--;
          s += 'R';
        } else
          break;
      }
    } else {
      if (top < arr[r]) {
        top = arr[r];
        r--;
        s += 'R';
      } else {
        if (top < arr[l]) {
          top = arr[l];
          l++;
          s += 'L';
        } else
          break;
      }
    }
  }
  cout << s.size() << endl;
  cout << s << endl;
  return 0;
}
