#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  long long int i;
  long long int a[n];
  for (long long int i = 0; i < n; i++) cin >> a[i];
  vector<char> v;
  long long int ma = 0;
  long long int j = n - 1;
  i = 0;
  if (a[i] > a[j]) {
    if (a[j] > ma) {
      ma = a[j];
      j--;
      v.push_back('R');
    }
  } else {
    ma = a[i];
    i++;
    v.push_back('L');
  }
  long long int f = 0;
  while (i <= j) {
    f = 0;
    if (a[i] < a[j]) {
      if (a[i] > ma) {
        ma = a[i];
        i++;
        f++;
        v.push_back('L');
      } else if (a[j] > ma) {
        ma = a[j];
        j--;
        f++;
        v.push_back('R');
      }
    } else {
      if (a[j] > ma) {
        ma = a[j];
        j--;
        f++;
        v.push_back('R');
      } else if (a[i] > ma) {
        ma = a[i];
        i++;
        f++;
        v.push_back('L');
      }
    }
    if (f == 0) {
      break;
    }
  }
  cout << v.size() << endl;
  for (auto j : v) {
    cout << j;
  }
  return 0;
}
