#include <bits/stdc++.h>
int v[200000];
int ans[200000];
int main() {
  int n, i, st, dr, ant, ok, j;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &v[i]);
  }
  st = 0;
  dr = n - 1;
  if (v[st] < v[dr]) {
    ans[0] = 1;
    ant = v[st];
    st++;
  } else {
    ans[0] = 2;
    ant = v[dr];
    dr--;
  }
  ok = 1;
  i = 1;
  while (ok == 1 && st <= dr) {
    if (v[st] <= v[dr]) {
      if (v[st] > ant) {
        ans[i++] = 1;
        ant = v[st];
        st++;
      } else if (v[dr] > ant) {
        ans[i++] = 2;
        ant = v[dr];
        dr--;
      } else
        ok = 0;
    } else {
      if (v[dr] > ant) {
        ans[i++] = 2;
        ant = v[dr];
        dr--;
      } else if (v[st] > ant) {
        ans[i++] = 1;
        ant = v[st];
        st++;
      } else
        ok = 0;
    }
  }
  printf("%d\n", i);
  for (j = 0; j < i; j++) {
    if (ans[j] == 1)
      printf("L");
    else
      printf("R");
  }
  return 0;
}
