#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAX_N = 2e5 + 10;
int num[MAX_N];
char ans[MAX_N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &num[i]);
  int nAns = 0;
  int left = 0, right = n - 1;
  int temp = 0;
  while (true) {
    if (left > right) break;
    if (temp > num[left] && temp > num[right])
      break;
    else if (temp < num[left] && temp < num[right]) {
      if (num[left] < num[right])
        ans[nAns++] = 'L', temp = num[left], ++left;
      else
        ans[nAns++] = 'R', temp = num[right], --right;
    } else if (temp < num[left])
      ans[nAns++] = 'L', temp = num[left], ++left;
    else
      ans[nAns++] = 'R', temp = num[right], --right;
  }
  printf("%d\n%s", nAns, ans);
  return 0;
}
