#include <bits/stdc++.h>
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
inline long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
inline long long power(long long a, long long n, long long m) {
  if (n == 0) return 1;
  long long p = power(a, n / 2, m);
  p = (p * p) % m;
  if (n % 2)
    return (p * a) % m;
  else
    return p;
}
const long long MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const long long LL_INF = 0x3f3f3f3f3f3f3f3f;
int32_t main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  long long last = 0, i = 0, j = n - 1, mn;
  vector<char> ans;
  while (i <= j) {
    mn = max(a[i], a[j]);
    if (mn > last) {
      if (a[i] < a[j]) {
        if (a[i] > last) {
          ans.push_back('L');
          last = a[i];
          i++;
        } else {
          ans.push_back('R');
          last = a[j];
          j--;
        }
      } else {
        if (a[j] > last) {
          ans.push_back('R');
          last = a[j];
          j--;
        } else {
          ans.push_back('L');
          last = a[i];
          i++;
        }
      }
    } else
      break;
  }
  cout << ans.size() << "\n";
  for (long long i = 0; i < ans.size(); i++) cout << ans[i];
  cout << "\n";
  return 0;
}
