#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000000 + 7;
int main() {
  string s;
  long long n;
  cin >> n;
  long long a[n];
  for (int i = 0; i < n; ++i) cin >> a[i];
  long long x = 0, y = n - 1, z = 0;
  while (x <= y) {
    if (max(a[x], a[y]) < z)
      break;
    else {
      if (a[x] < a[y] && a[x] > z) {
        z = a[x];
        s += 'L';
        x++;
      } else if (a[y] > z) {
        z = a[y];
        s += 'R';
        y--;
      } else {
        z = a[x];
        s += 'L';
        x++;
      }
    }
  }
  cout << s.size() << endl;
  cout << s;
  return 0;
}
