#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n;
int a[maxn];
int mx = 0;
string ans = "";
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  int i = 0, j = n - 1;
  while (a[i] != a[j]) {
    if (a[i] < a[j]) {
      if (a[i] <= mx) break;
      ans += 'L';
      mx = max(mx, a[i]);
      i++;
    } else {
      if (a[j] <= mx) break;
      ans += 'R';
      mx = max(mx, a[j]);
      j--;
    }
  }
  int res1 = 0;
  int res2 = 0;
  int mx2 = mx;
  while (a[i] > mx) {
    mx = max(mx, a[i]);
    i++;
    res1++;
  }
  while (a[j] > mx2) {
    mx2 = max(mx2, a[j]);
    res2++;
    j--;
  }
  if (res2 > res1)
    for (int i = 0; i < res2; i++) ans += 'R';
  else
    for (int i = 0; i < res1; i++) ans += 'L';
  cout << ans.size() << '\n' << ans;
  return 0;
}
