#include <bits/stdc++.h>
using namespace std;
int n;
int a[200001];
char mov[200001];
char mov1[200001];
int i, j;
int main() {
  scanf("%d", &n);
  int ans = 0;
  int ans1 = 0;
  int temp = 0;
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1, j = n; ans < n;) {
    if (a[i] > temp && a[i] < a[j]) {
      mov[++ans] = 'L';
      temp = a[i];
      i++;
    } else if (a[j] > temp && a[j] <= a[i] || a[j] > temp && a[i] <= temp) {
      mov[++ans] = 'R';
      temp = a[j];
      j--;
    } else if (a[i] > temp) {
      mov[++ans] = 'L';
      temp = a[i];
      i++;
    } else
      break;
  }
  temp = 0;
  for (i = 1, j = n; ans < n;) {
    if (a[i] > temp && a[i] <= a[j]) {
      mov1[++ans1] = 'L';
      temp = a[i];
      i++;
    } else if (a[j] > temp && a[j] <= a[i] || a[j] > temp && a[i] <= temp) {
      mov1[++ans1] = 'R';
      temp = a[j];
      j--;
    } else if (a[i] > temp) {
      mov1[++ans1] = 'L';
      temp = a[i];
      i++;
    } else
      break;
  }
  if (ans >= ans1) {
    printf("%d\n", ans);
    for (i = 1; i <= ans; i++) cout << mov[i];
  } else {
    printf("%d\n", ans1);
    for (i = 1; i <= ans1; i++) cout << mov1[i];
  }
}
