#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  list<int> l, l1;
  while (n--) {
    int ch;
    cin >> ch;
    l.push_back(ch);
  }
  string second = "";
  int c = 0;
  while (1) {
    if (l.front() < l.back() && l.front() > l1.back()) {
      l1.push_back(l.front());
      l.pop_front();
      c++;
      second += 'L';
    } else if (l.back() < l.front() && l.back() > l1.back()) {
      l1.push_back(l.back());
      l.pop_back();
      c++;
      second += 'R';
    } else if (l.front() > l1.back()) {
      l1.push_back(l.front());
      l.pop_front();
      c++;
      second += 'L';
    } else if (l.back() > l1.back()) {
      l1.push_back(l.back());
      l.pop_back();
      c++;
      second += 'R';
    } else
      break;
    if (l.empty()) break;
  }
  cout << c << endl;
  cout << second;
  return 0;
}
