#include <bits/stdc++.h>
using namespace std;
long long int const mod = 1e9 + 7;
long long int const inf = 1e15 + 7;
long long int const mxn = 1e5 + 1;
inline void file() {}
int main() {
  file();
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  {
    long long int n;
    cin >> n;
    long long int a[n];
    for (long long int i = 0; i < n; i++) cin >> a[i];
    vector<long long int> v;
    string s;
    v.push_back(0);
    long long int st = 0, la = n - 1;
    while (st <= la) {
      if (((a[st] <= a[la]) && (a[st] > v.back())) ||
          ((a[st] > v.back()) && (a[la] < v.back()))) {
        v.push_back(a[st]);
        s += 'L';
        st++;
      } else if (((a[la] < a[st]) && (a[la] > v.back())) ||
                 ((a[st] < v.back()) && (a[la] > v.back()))) {
        v.push_back(a[la]);
        s += 'R';
        la--;
      } else
        break;
    }
    cout << s.size() << "\n";
    cout << s << "\n";
  }
}
