#include <bits/stdc++.h>
using namespace std;
int n, a[200001], i1, i2, x;
string ans;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  i1 = 1, i2 = n;
  while (i1 <= i2) {
    if (a[i1] < a[i2]) {
      if (a[i1] <= x) {
        if (a[i2] <= x) break;
        ans.push_back('R');
        x = a[i2];
        i2--;
        continue;
      }
      ans.push_back('L');
      x = a[i1];
      i1++;
    } else {
      if (a[i2] <= x) {
        if (a[i1] <= x) break;
        ans.push_back('L');
        x = a[i1];
        i1++;
        continue;
      }
      ans.push_back('R');
      x = a[i2];
      i2--;
    }
  }
  cout << ans.size() << '\n';
  cout << ans << '\n';
  return 0;
}
