#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<char> v;
  int l = 0, r = n - 1;
  long long int rec = 0;
  while (l <= r) {
    if (a[l] > rec && a[r] > rec) {
      if (a[l] > a[r]) {
        rec = a[r];
        r--;
        v.push_back('R');
      } else {
        rec = a[l];
        l++;
        v.push_back('L');
      }
    } else if (a[l] > rec) {
      rec = a[l];
      l++;
      v.push_back('L');
    } else if (a[r] > rec) {
      rec = a[r];
      r--;
      v.push_back('R');
    } else {
      break;
    }
  }
  cout << v.size() << endl;
  for (int i = 0; i < v.size(); i++) {
    cout << v[i];
  }
  cout << endl;
}
