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