#include <bits/stdc++.h>
using namespace std;
bool func(const pair<long long, long long> &a,
          const pair<long long, long long> &b) {
  return a.second < b.second;
}
long long int power(long long int a, long long int b) {
  long long int res = 1;
  a %= 998244353;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % 998244353;
    a = a * a % 998244353;
  }
  return res;
}
long long int modInverse(long long int a) { return power(a, 998244353 - 2); }
void solve() {
  long long int n, x;
  cin >> n;
  vector<long long int> v(n);
  for (long long int i = 0; i < n; ++i) cin >> v[i];
  long long int le = 0, re = n - 1;
  long long int curr = 0;
  int flg = 1;
  vector<char> ans;
  while (le <= re) {
    if (v[le] <= v[re]) {
      if (v[le] > curr) {
        curr = v[le];
        le++;
        ans.push_back('L');
      } else if (v[re] > curr) {
        curr = v[re];
        re--;
        ans.push_back('R');
      } else
        break;
    } else {
      if (v[re] > curr) {
        curr = v[re];
        re--;
        ans.push_back('R');
      } else if (v[le] > curr) {
        curr = v[le];
        le++;
        ans.push_back('L');
      } else
        break;
    }
  }
  cout << ans.size() << '\n';
  for (char c : ans) cout << c;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1, tmp = 0;
  while (t--) {
    solve();
    if (t) cout << "\n";
  }
  cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
  return 0;
}
