#include <bits/stdc++.h>
using namespace std;
void solve();
void fastIO() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
int main() {
  fastIO();
  solve();
}
void solve() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int f, b, l;
  f = 0;
  b = n - 1;
  l = INT_MIN;
  string s;
  while (true) {
    if (f > b) break;
    if (a[f] > l && a[b] > l) {
      if (a[f] < a[b]) {
        l = a[f];
        s.push_back('L');
        f++;
      } else {
        l = a[b];
        s.push_back('R');
        b--;
      }
    } else if (a[b] > l) {
      l = a[b];
      s.push_back('R');
      b--;
    } else if (a[f] > l) {
      l = a[f];
      s.push_back('L');
      f++;
    } else {
      break;
    }
  }
  cout << s.length() << '\n' << s;
  return;
}
