#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long int n, cur = 0, count = 0;
  cin >> n;
  vector<long int> v(n);
  for (long int i = 0; i < n; i++) cin >> v[i];
  long int l = 0, r = n - 1;
  string s;
  while (l <= r) {
    if (v[l] > cur && v[r] > cur) {
      cur = min(v[l], v[r]);
      count++;
      (cur == v[l]) ? s.push_back('L') : s.push_back('R');
      (cur == v[l]) ? l++ : r--;
    } else if (v[l] > cur) {
      cur = v[l];
      l++;
      count++;
      s.push_back('L');
    } else if (v[r] > cur) {
      cur = v[r];
      r--;
      count++;
      s.push_back('R');
    } else
      break;
  }
  cout << count << endl << s;
  return 0;
}
