#include <bits/stdc++.h>
int main() {
  int n, tmp;
  std::cin >> n;
  std::vector<int> v(n);
  std::deque<int> dq;
  for (int i = 0; i < n; ++i) {
    std::cin >> tmp;
    dq.emplace_back(tmp);
  }
  std::string actions;
  int last = -1;
  while (!dq.empty()) {
    char action = '\0';
    if (dq.front() >= last && (dq.front() < dq.back() || dq.back() < last)) {
      action = 'L';
    } else if (dq.back() >= last &&
               (dq.front() >= dq.back() || dq.front() < last)) {
      action = 'R';
    }
    if (action == 'L') {
      actions += 'L';
      last = dq.front();
      dq.pop_front();
    } else if (action == 'R') {
      actions += 'R';
      last = dq.back();
      dq.pop_back();
    } else {
      break;
    }
  }
  std::cout << actions.length() << '\n' << actions << '\n';
}
