#include <bits/stdc++.h>
using namespace std;
long long n;
long long a[10000111];
long long b[10000111];
string c;
long long mx = 0;
long long dem = 0;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  long long i = 1;
  long long j = n;
  while (i <= j) {
    if (i == j && a[i] > mx) {
      dem++;
      c = c + "R";
      break;
    }
    if (a[i] > mx && a[j] > mx && a[i] > a[j]) {
      mx = a[j];
      c = c + "R";
      j--;
      dem++;
    } else if (a[i] > mx && a[j] > mx && a[j] > a[i]) {
      mx = a[i];
      c = c + "L";
      i++;
      dem++;
    } else if (a[i] > mx) {
      mx = a[i];
      c = c + "L";
      i++;
      dem++;
    } else if (a[j] > mx) {
      mx = a[j];
      c = c + "R";
      j--;
      dem++;
    } else
      break;
  }
  cout << dem << endl;
  cout << c;
}
