#include <bits/stdc++.h>
const int oo = 0x7fffffff;
const long long OO = 0x7fffffffffffffff;
template <class T>
std::ostream& operator<<(std::ostream& O, const std::vector<T>& V) {
  for (const T& x : V) O << x << " ";
  O << "\n";
  return O;
}
template <class T1, class T2>
std::ostream& operator<<(std::ostream& O, const std::pair<T1, T2>& P) {
  return O << "(" << P.first << ", " << P.second << ")";
}
std::mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count());
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
  std::cout.tie(0);
  ;
  int n;
  cin >> n;
  vector<int> V(n);
  for (auto& x : V) cin >> x;
  int i = 0, j = n - 1;
  int l = 0, last = 0;
  string s;
  while (i <= j) {
    ;
    ;
    if (V[i] > last and V[j] > last) {
      if (V[i] > V[j]) {
        last = V[j];
        s += 'R';
        j--;
      } else {
        last = V[i];
        s += 'L';
        ++i;
      }
    } else if (V[i] > last) {
      last = V[i];
      s += 'L';
      ++i;
    } else if (V[j] > last) {
      last = V[j];
      s += 'R';
      j--;
    } else
      break;
  }
  cout << s.size() << "\n" << s << "\n";
  return 0;
}
