#include <bits/stdc++.h>
using namespace std;
bool isvowel(char c) {
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
    return true;
  else
    return false;
}
bool isprime(long long int n) {
  for (long long int i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) return false;
  }
  return true;
}
long long int power(long long int a, long long int b) {
  if (b == 0) return 1;
  if (b == 1) return a;
  long long int temp = power(a, b / 2);
  if (b % 2 == 0)
    return temp * temp;
  else
    return temp * temp * a;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  long long int a[n], left = 0, right = n - 1;
  for (long long int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long int p = 0, count1 = 0;
  string second = "";
  while (left <= right) {
    if (a[left] > p && a[right] > p) {
      if (a[left] < a[right]) {
        count1++;
        second += "L";
        p = a[left];
        left++;
      } else {
        count1++;
        second += "R";
        p = a[right];
        right--;
      }
    } else if (a[left] > p) {
      count1++;
      second += "L";
      p = a[left];
      left++;
    } else if (a[right] > p) {
      count1++;
      second += "R";
      p = a[right];
      right--;
    } else
      break;
  }
  cout << count1 << endl << second;
  return 0;
}
