#include <bits/stdc++.h>
inline int read(void) {
  register int x = 0, f = 1, ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -f;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int maxn = 200005;
int n, last, tot, a[maxn];
bool f[maxn];
int main(void) {
  n = read();
  for (register int i = 1; i <= n; ++i) a[i] = read();
  last = 1 << 31;
  int left = 1, right = n;
  while (left <= right) {
    if (left == right) {
      if (a[left] > last) f[++tot] = 0;
      break;
    } else if (a[left] != a[right])
      if (a[left] < a[right])
        if (a[left] > last) {
          f[++tot] = 0;
          last = a[left++];
        } else if (a[right] > last) {
          f[++tot] = 1;
          last = a[right--];
        } else
          break;
      else if (a[right] > last) {
        f[++tot] = 1;
        last = a[right--];
      } else if (a[left] > last) {
        f[++tot] = 0;
        last = a[left++];
      } else
        break;
    else {
      int lasta = last, tota = 0, lastb = last, totb = 0;
      for (register int i = left; i <= right; ++i)
        if (a[i] > lasta) {
          lasta = a[i];
          ++tota;
        } else
          break;
      for (register int i = right; i >= left; --i)
        if (a[i] > lastb) {
          lastb = a[i];
          ++totb;
        } else
          break;
      if (tota > totb) {
        while (tota--) f[++tot] = 0;
        break;
      } else {
        while (totb--) f[++tot] = 1;
        break;
      }
    }
  }
  printf("%d\n", tot);
  for (register int i = 1; i <= tot; ++i) printf("%c", f[i] ? 'R' : 'L');
  return 0;
}
