#include <bits/stdc++.h>
using namespace std;
int a[2 * 100005];
void solve(int i, int j, int curr, vector<int> &v) {
  if (i > j) return;
  if (a[curr] < a[i] && a[curr] < a[j]) {
    if (a[i] > a[j]) {
      v.push_back(1);
      solve(i, j - 1, j, v);
    } else {
      v.push_back(0);
      solve(i + 1, j, i, v);
    }
  } else if (a[curr] < a[i]) {
    v.push_back(0);
    solve(i + 1, j, i, v);
  } else if (a[curr] < a[j]) {
    v.push_back(1);
    solve(i, j - 1, j, v);
  }
  return;
}
int main() {
  vector<int> v;
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  solve(1, n, 0, v);
  cout << v.size() << endl;
  for (int i = 0; i < v.size(); i++) {
    if (v[i]) {
      cout << "R";
    } else
      cout << "L";
  }
  cout << endl;
  return 0;
}
