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