#include <bits/stdc++.h>
using namespace std;
int f[200001];
int main() {
  ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
  int n;
  cin >> n;
  for (int i = 0; i < (int)(n); ++i) cin >> f[i];
  int i = 0, j = n - 1, cur = 0;
  string ans = "";
  while (j >= i) {
    if (cur < f[i] && cur < f[j])
      if (f[j] > f[i]) {
        ans += "L";
        cur = f[i++];
      } else {
        ans += "R";
        cur = f[j--];
      }
    else if (cur < f[i]) {
      ans += "L";
      cur = f[i++];
    } else if (cur < f[j]) {
      ans += "R";
      cur = f[j--];
    } else
      break;
  }
  cout << (int)(ans).size() << "\n";
  for (int i = 0; i < (int)((int)(ans).size()); ++i) cout << ans[i];
  return 0;
}
