#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable : 4996)
int main() {
  int n;
  scanf("%d", &n);
  vector<int> PAMAGITE(n);
  for (int i = 0; i < n; i++) scanf("%d", &PAMAGITE[i]);
  string MAT_EBAL = "";
  int l = 0, r = n - 1, LAST_BLEAT;
  if (PAMAGITE[l] > PAMAGITE[r]) {
    LAST_BLEAT = PAMAGITE[r];
    r--;
    MAT_EBAL += "R";
  } else {
    LAST_BLEAT = PAMAGITE[l];
    l++;
    MAT_EBAL += "L";
  }
  while (l <= r) {
    if (PAMAGITE[l] > LAST_BLEAT && PAMAGITE[r] > LAST_BLEAT) {
      if (PAMAGITE[l] <= PAMAGITE[r]) {
        LAST_BLEAT = PAMAGITE[l];
        l++;
        MAT_EBAL += "L";
      } else {
        LAST_BLEAT = PAMAGITE[r];
        r--;
        MAT_EBAL += "R";
      }
    } else if (PAMAGITE[l] > LAST_BLEAT) {
      LAST_BLEAT = PAMAGITE[l];
      l++;
      MAT_EBAL += "L";
    } else if (PAMAGITE[r] > LAST_BLEAT) {
      LAST_BLEAT = PAMAGITE[r];
      r--;
      MAT_EBAL += "R";
    } else
      break;
  }
  printf("%d\n", MAT_EBAL.length());
  cout << MAT_EBAL;
  return 0;
}
