#include <bits/stdc++.h>
using namespace std;
const int N = 3e5, M = N;
const long long infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
void solve() {
  long long n;
  cin >> n;
  ;
  deque<int> q;
  int st = 0, end = n - 1;
  for (long long i = 0; i < n; i++) {
    long long c;
    cin >> c;
    q.push_back(c);
  }
  int inq = INT_MIN;
  string s = "";
  while (st <= end) {
    int mn = min(q.front(), q.back());
    if (mn > inq) {
      if (mn == q.front()) {
        s += "L";
        inq = mn;
        st++;
        q.pop_front();
      } else {
        s += "R";
        inq = mn;
        end--;
        q.pop_back();
      }
    } else {
      if (q.front() > inq) {
        s += "L", inq = q.front();
        st++;
        q.pop_front();
      } else if (q.back() > inq) {
        s += "R";
        inq = q.back();
        end--;
        q.pop_back();
      } else
        break;
    }
  }
  cout << s.length() << endl;
  cout << s << endl;
}
int main() {
  { solve(); }
  return 0;
}
