#include <bits/stdc++.h>
const int MAX_N = 2 * 1e5;
int arr[MAX_N + 10];
std::string ans;
int main() {
  std::cin.tie(NULL);
  std::cout.tie(NULL);
  std::ios_base::sync_with_stdio(false);
  int n;
  std::cin >> n;
  for (int i = 0; i < n; ++i) {
    std::cin >> arr[i];
  }
  int curr = 0, l = 0, r = n - 1, num = 0;
  while (l <= r) {
    if (curr > arr[l] && curr > arr[r]) {
      break;
    }
    if (curr < arr[l] && curr > arr[r]) {
      ans.push_back('L');
      ++num;
      curr = arr[l];
      ++l;
    } else if (curr > arr[l] && curr < arr[r]) {
      ans.push_back('R');
      ++num;
      curr = arr[r];
      --r;
    } else {
      if (arr[l] < arr[r]) {
        ans.push_back('L');
        ++num;
        curr = arr[l];
        ++l;
      } else {
        ans.push_back('R');
        ++num;
        curr = arr[r];
        --r;
      }
    }
  }
  std::cout << num << '\n' << ans << '\n';
  return 0;
}
