#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int T = 1;
  while (T) {
    int n;
    cin >> n;
    int a[n];
    for (long long i = 0; i < n; i++) cin >> a[i];
    int l = 0, r = n - 1;
    string ans = "";
    int temp = 0;
    int count = 0;
    while (1) {
      count = 0;
      if (a[l] > a[r]) {
        if (a[r] > temp) {
          count = -1;
          temp = a[r];
          ans += 'R';
          r--;
        } else if (a[l] > temp) {
          count = -1;
          temp = a[l];
          ans += 'L';
          l++;
        }
        if (l > r) break;
      } else {
        if (a[l] > temp) {
          count = -1;
          temp = a[l];
          ans += 'L';
          l++;
        } else if (a[r] > temp) {
          count = -1;
          temp = a[r];
          ans += 'R';
          r--;
        }
        if (l > r) break;
      }
      if (count != -1) break;
    }
    cout << ans.length() << "\n" << ans;
    T--;
  }
  return 0;
}
