#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int _inf = 0xc0c0c0c0;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const long long _INF = 0xc0c0c0c0c0c0c0c0;
const long long mod = (int)1e9 + 7;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long ksm(long long a, long long b, long long mod) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}
long long inv2(long long a, long long mod) { return ksm(a, mod - 2, mod); }
void exgcd(long long a, long long b, long long &x, long long &y, long long &d) {
  if (!b) {
    d = a;
    x = 1;
    y = 0;
  } else {
    exgcd(b, a % b, y, x, d);
    y -= x * (a / b);
  }
}
const int MAX_N = 200025;
int arr[MAX_N];
int main() {
  int n, ans = 0, now = 0;
  string ANS = "";
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &arr[i]);
  int l = 1, r = n;
  while (l <= r) {
    if (arr[l] <= now && arr[r] <= now)
      break;
    else {
      if (arr[l] > now && arr[r] > now) {
        if (arr[l] > arr[r]) {
          now = arr[r];
          ANS += 'R';
          ans++;
          r--;
        } else {
          now = arr[l];
          ANS += 'L';
          ans++;
          l++;
        }
      } else if (arr[l] > now) {
        now = arr[l];
        ANS += 'L';
        ans++;
        l++;
      } else {
        now = arr[r];
        ANS += 'R';
        ans++;
        r--;
      }
    }
  }
  printf("%d\n", ans);
  printf("%s\n", ANS.c_str());
  return 0;
}
