#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> vec;
  for (int i = 1; i <= n; i++) {
    int input;
    cin >> input;
    vec.push_back(input);
  }
  int low = 0, high = n - 1;
  string ans;
  vector<int> vec_check;
  if (vec[low] < vec[high]) {
    ans.push_back('L');
    vec_check.push_back(vec[low]);
    low++;
  } else {
    ans.push_back('R');
    vec_check.push_back(vec[high]);
    high--;
  }
  while (low <= high) {
    if (max(vec[low], vec[high]) < vec_check[vec_check.size() - 1]) break;
    if (vec[low] < vec[high]) {
      if (vec[low] > vec_check[vec_check.size() - 1]) {
        vec_check.push_back(vec[low]);
        ans.push_back('L');
        low++;
      } else {
        vec_check.push_back(vec[high]);
        ans.push_back('R');
        high--;
      }
    } else {
      if (vec[high] > vec_check[vec_check.size() - 1]) {
        vec_check.push_back(vec[high]);
        ans.push_back('R');
        high--;
      } else {
        vec_check.push_back(vec[low]);
        ans.push_back('L');
        low++;
      }
    }
  }
  cout << ans.size() << "\n";
  cout << ans;
  return 0;
}
