#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007, inf = -1e18;
long long n, i, j, ans, cnt, a[500005];
vector<char> s;
char o[20];
int main() {
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  i = 0;
  j = n - 1;
  long long mx = 0;
  while (i <= j) {
    if (a[i] < a[j] && a[i] > mx) {
      mx = a[i];
      s.push_back('L');
      i++;
    } else if (a[i] > a[j] && a[j] > mx) {
      mx = a[j];
      s.push_back('R');
      j--;
    } else if (a[i] > mx) {
      mx = a[i];
      s.push_back('L');
      i++;
    } else if (a[j] > mx) {
      mx = a[j];
      s.push_back('R');
      j--;
    } else {
      break;
    }
    cnt++;
    if (i > j) break;
  }
  cout << cnt << endl;
  for (auto it : s) cout << it;
  return 0;
}
