#include <bits/stdc++.h>
using namespace std;
int n, p, q, st;
int a[200005];
vector<char> ans;
int main() {
  ios::sync_with_stdio(false);
  ;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  if (n == 1) {
    cout << 1 << endl << 'L' << endl;
    return 0;
  }
  if (a[1] > a[n]) {
    st = a[n];
    p = 1;
    q = n - 1;
    ans.push_back('R');
  } else {
    st = a[1];
    p = 2;
    q = n;
    ans.push_back('L');
  }
  while (p <= q) {
    if (a[p] < st && a[q] < st)
      break;
    else if (a[p] < st && a[q] > st) {
      st = a[q];
      q--;
      ans.push_back('R');
    } else if (a[p] > st && a[q] < st) {
      st = a[p];
      p++;
      ans.push_back('L');
    } else {
      if (a[p] > a[q]) {
        st = a[q];
        q--;
        ans.push_back('R');
      } else {
        st = a[p];
        p++;
        ans.push_back('L');
      }
    }
  }
  cout << ans.size() << endl;
  for (auto i : ans) cout << i;
  return 0;
}
