#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> v(200000);
  int max_str_len = 0;
  int l, r, val = -10000, n;
  string res = "";
  cin >> n;
  l = 0;
  r = n - 1;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  while (l <= r && (v[l] > val || v[r] > val)) {
    if (v[l] <= v[r]) {
      if (v[l] > val) {
        val = v[l];
        l++;
        res += "L";
      } else if (v[r] > val) {
        val = v[r];
        r--;
        res += "R";
      }
    } else {
      if (v[r] > val) {
        val = v[r];
        r--;
        res += "R";
      } else if (v[l] > val) {
        val = v[l];
        l++;
        res += "L";
      }
    }
    max_str_len++;
  }
  cout << max_str_len << endl << res;
  return 0;
}
