#include <bits/stdc++.h>
using namespace std;
bool vis[1000] = {0};
vector<int> v[1000];
int main() {
  long long n;
  cin >> n;
  long long a[n], i, j;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  i = 0;
  j = n - 1;
  string s = "";
  long long c = 0, m = 0;
  while (i <= j) {
    if (a[i] > a[j]) {
      if (a[j] > m) {
        s = s + "R";
        m = a[j];
        j--;
      } else if (a[i] > m) {
        s = s + "L";
        m = a[i];
        i++;
      } else
        break;
    } else {
      if (a[i] > m) {
        s = s + "L";
        m = a[i];
        i++;
      } else if (a[j] > m) {
        s = s + "R";
        m = a[j];
        j--;
      } else
        break;
    }
  }
  cout << s.length() << endl;
  cout << s;
}
