#include <bits/stdc++.h>
using namespace std;
template <typename T>
using V = vector<T>;
template <typename T>
using VV = vector<V<T>>;
template <typename T>
istream& operator>>(istream& cin, V<T>& arr) {
  for (T& val : arr) {
    cin >> val;
  }
  return cin;
}
template <typename T>
ostream& operator<<(ostream& cout, V<T>& arr) {
  for (T& val : arr) {
    cout << val << " ";
  }
  return cout;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<long long> v(n);
  cin >> v;
  string ans = "";
  long long l = 0;
  long long r = n - 1;
  long long maxNum = 0;
  while (l <= r && (maxNum < v[l] || maxNum < v[r])) {
    if (v[r] < maxNum || v[l] < v[r] && v[l] > maxNum) {
      maxNum = v[l];
      ans += 'L';
      l++;
    } else {
      maxNum = v[r];
      ans += 'R';
      r--;
    }
  }
  cout << ans.size() << '\n' << ans;
  return 0;
}
