#include <bits/stdc++.h>
const long long N = 2 * 1e5 + 7;
using namespace std;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<long long> a(n, 0), arr;
  for (long long i = 0; i < n; i++) cin >> a[i];
  vector<char> str;
  long long l = 0, r = n - 1;
  if (a[l] < a[r]) {
    str.push_back('L');
    arr.push_back(a[l]);
    l++;
  } else {
    str.push_back('R');
    arr.push_back(a[r]);
    r--;
  }
  for (long long i = 0; i < n; i++) {
    if (a[l] < a[r] && a[l] > arr[arr.size() - 1]) {
      str.push_back('L');
      arr.push_back(a[l]);
      l++;
    } else if (a[l] < a[r] && a[l] < arr[arr.size() - 1] &&
               a[r] > arr[arr.size() - 1]) {
      str.push_back('R');
      arr.push_back(a[r]);
      r--;
    } else if (a[l] > a[r] && a[r] > arr[arr.size() - 1]) {
      str.push_back('R');
      arr.push_back(a[r]);
      r--;
    } else if (a[l] > a[r] && a[r] < arr[arr.size() - 1] &&
               a[l] > arr[arr.size() - 1]) {
      str.push_back('L');
      arr.push_back(a[l]);
      l++;
    } else
      break;
  }
  if (r - l == 0) {
    if (a[l] > arr[arr.size() - 1]) {
      arr.push_back(a[l]);
      str.push_back('R');
    }
  }
  cout << str.size() << "\n";
  for (long long i = 0; i < str.size(); i++) cout << str[i];
  return 0;
}
