#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n], b[n], len = n, j, i;
  string s1 = "";
  for (i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b, b + n);
  int start = 0;
  int end = n - 1;
  for (i = 0; i < n; i++) {
    if (b[i] == a[start]) {
      s1 = s1 + 'L';
      start = start + 1;
    } else if (b[i] == a[end]) {
      s1 = s1 + 'R';
      end = end - 1;
    } else {
      len = len - 1;
    }
  }
  cout << len << "\n";
  cout << s1;
}
