#include <bits/stdc++.h>
using namespace std;
string sh = "";
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, arr[200005];
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  int i = 1, j = n, goun = 0, last = 0, f = 0;
  while (1) {
    if (f == 1) break;
    if (i == j) {
      if (arr[j] > last) {
        goun++;
        sh += 'R';
      }
      break;
    } else if (i == 1 && j == n) {
      if (arr[i] < arr[j]) {
        goun++;
        last = arr[i];
        sh += 'L';
        i++;
      } else {
        goun++;
        last = arr[j];
        sh += 'R';
        j--;
      }
    } else {
      int ans = min(arr[i], arr[j]), ans2 = max(arr[i], arr[j]);
      if (ans > last) {
        if (arr[i] == ans) {
          goun++;
          last = arr[i];
          sh += 'L';
          i++;
        } else {
          goun++;
          last = arr[j];
          sh += 'R';
          j--;
        }
      } else if (ans2 > last) {
        if (arr[i] == ans2) {
          goun++;
          last = arr[i];
          sh += 'L';
          i++;
        } else {
          goun++;
          last = arr[j];
          sh += 'R';
          j--;
        }
      } else {
        f = 1;
      }
    }
  }
  cout << goun << "\n";
  cout << sh << "\n";
  return 0;
}
