#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n], i;
  int st = 0;
  int en = n - 1, count = 0, ma = INT_MIN;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  int prev = INT_MIN;
  string s = "", s1 = "", s2;
  while (st != en) {
    if (a[st] > prev || a[en] > prev) {
      if (a[st] > prev && a[en] > prev) {
        if (a[st] > a[en]) {
          prev = a[en];
          en--;
          s = s + "R";
        } else {
          prev = a[st];
          st++;
          s = s + "L";
        }
      } else if (a[st] > prev && a[en] < prev) {
        prev = a[st];
        st++;
        s = s + "L";
      } else if (a[st] < prev && a[en] > prev) {
        prev = a[en];
        en--;
        s = s + "R";
      }
      count++;
    } else {
      break;
    }
  }
  if (a[st] > prev) {
    count++;
    s = s + "L";
  }
  int maximum = INT_MIN;
  cout << count << "\n";
  cout << s;
}
