#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, i;
  cin >> n;
  long long int a[n + 1];
  for (i = 1; i <= n; i++) cin >> a[i];
  long long int left = 1, right = n, last;
  vector<char> v;
  if (a[left] < a[right]) {
    last = a[left];
    left++;
    v.push_back('L');
  } else {
    last = a[right];
    right--;
    v.push_back('R');
  }
  while (left <= right) {
    if (a[left] > last && a[right] > last) {
      if (a[left] < a[right]) {
        last = a[left];
        left++;
        v.push_back('L');
      } else {
        last = a[right];
        right--;
        v.push_back('R');
      }
    } else if (a[left] < last && a[right] < last) {
      break;
    } else if (a[left] < last) {
      last = a[right];
      right--;
      v.push_back('R');
    } else {
      last = a[left];
      left++;
      v.push_back('L');
    }
  }
  cout << v.size() << "\n";
  ;
  for (i = 0; i < v.size(); i++) {
    cout << v[i];
  }
}
