#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  long long int arr[200005];
  stack<int> q;
  q.push(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  if (n == 1) {
    cout << 1 << endl;
    cout << "L" << endl;
    return 0;
  }
  int l = 1, r = n;
  string s = "";
  int i = 0;
  bool L = false, R = false;
  bool ok = false;
  while (l != r) {
    if (L && R) break;
    if (arr[l] < arr[r] && i == 0) {
      q.push(arr[l]);
      l++;
      s += 'L';
      i++;
    } else if (arr[r] < arr[l] && i == 0) {
      q.push(arr[r]);
      r--;
      s += 'R';
      i++;
    } else if (arr[l] < arr[r]) {
      if (q.top() < arr[l] && L == false) {
        q.push(arr[l]);
        l++;
        s += 'L';
      } else if (q.top() < arr[r] && R == false) {
        q.push(arr[r]);
        r--;
        s += 'R';
      } else {
        L = true;
        R = true;
      }
    } else if (arr[r] < arr[l]) {
      if (q.top() < arr[r] && R == false) {
        q.push(arr[r]);
        r--;
        s += 'R';
      } else if (q.top() < arr[l] && L == false) {
        q.push(arr[l]);
        l++;
        s += 'L';
      } else {
        R = true;
        L = true;
      }
    }
  }
  if (q.top() < arr[l] && s.size() == n - 1) {
    s += 'L';
  }
  cout << s.size() << endl;
  cout << s << endl;
  return 0;
}
