#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n;
  int a[n];
  vector<char> ans;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int start = 0, end = n - 1, prev = -1;
  while (start <= end) {
    if (a[start] > a[end] && a[end] > prev) {
      ans.push_back('R');
      prev = a[end];
      end--;
    } else if (a[start] < a[end] && a[start] > prev) {
      ans.push_back('L');
      prev = a[start];
      start++;
    } else if (a[start] > prev) {
      ans.push_back('L');
      prev = a[start];
      start++;
    } else if (a[end] > prev) {
      ans.push_back('R');
      prev = a[end];
      end--;
    } else
      break;
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i];
  }
  return 0;
}
