#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  int n, i;
  cin >> n;
  long long a[n + 1], max = 0;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  int p = 0, q = n - 1;
  vector<long long> v;
  string s = "";
  while (p < q) {
    if (a[p] < a[q]) {
      if (max < a[p]) {
        v.push_back(a[p]);
        max = a[p];
        p++;
        s += 'L';
      } else if (max < a[q]) {
        v.push_back(a[q]);
        max = a[q];
        q--;
        s += 'R';
      } else {
        break;
      }
    } else if (a[q] < a[p]) {
      if (max < a[q]) {
        v.push_back(a[q]);
        max = a[q];
        q--;
        s += 'R';
      } else if (max < a[p]) {
        v.push_back(a[p]);
        max = a[p];
        p++;
        s += 'L';
      } else {
        break;
      }
    }
  }
  if (p == q) {
    if (a[p] > max) {
      v.push_back(a[p]);
      s += 'L';
    }
  }
  cout << v.size() << "\n";
  cout << s << "\n";
  return 0;
}
