#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long arr[n + 1];
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
  }
  long long st = 0, en = n - 1;
  string ans = "";
  long long cnt = 0, prev = 0, flg = 0;
  while (st < n && en >= 0 && st <= en) {
    if (arr[st] >= arr[en]) {
      if (arr[en] >= prev) {
        ans.push_back('R');
        prev = arr[en];
        en--;
        cnt++;
        continue;
      } else if (arr[st] >= prev) {
        ans.push_back('L');
        prev = arr[st];
        st++;
        cnt++;
        continue;
      }
    } else if (arr[st] < arr[en]) {
      if (arr[st] >= prev) {
        ans.push_back('L');
        prev = arr[st];
        st++;
        cnt++;
        continue;
      } else if (arr[en] >= prev) {
        ans.push_back('R');
        prev = arr[en];
        en--;
        cnt++;
        continue;
      }
    }
    flg++;
    if (flg >= n + 10) {
      break;
    }
  }
  cout << cnt << endl;
  cout << ans << endl;
}
