#include <bits/stdc++.h>
using namespace std;
int n;
int a[200005];
int ans = 0;
int d[200005];
int k0 = 1;
int p0 = 0;
char s0[200005];
int main() {
  scanf("%d", &n);
  d[0] = 0;
  int r0 = n;
  for (int j = 1; j <= n; j++) scanf("%d", &a[j]);
  int i = 1;
  for (i = 1; i < r0; i++) {
    if (a[i] < d[k0 - 1] && a[r0] < d[k0 - 1]) break;
    if (a[i] > a[r0] && a[r0] > d[k0 - 1] ||
        a[i] < d[k0 - 1] && a[r0] > d[k0 - 1]) {
      d[k0++] = a[r0];
      r0--;
      i--;
      s0[p0++] = 'R';
      ans++;
    } else if (a[i] < a[r0] && a[i] > d[k0 - 1] ||
               a[i] > d[k0 - 1] && a[r0] < d[k0 - 1]) {
      d[k0++] = a[i];
      s0[p0++] = 'L';
      ans++;
    }
  }
  if (i == r0 && a[i] > d[k0 - 1]) {
    s0[p0++] = 'R';
    ans++;
  }
  printf("%d\n", ans);
  for (int j = 0; j < p0; j++) printf("%c", s0[j]);
  return 0;
}
