#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
int a[MAXN];
vector<bool> lts;
vector<int> ori;
vector<int> rev;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }
  int last = -1;
  int lt = 1;
  int rt = n;
  bool sameFlag = false;
  while (lt <= rt) {
    if (a[lt] > last && a[rt] > last) {
      if (a[lt] < a[rt]) {
        lts.push_back(true);
        last = a[lt];
        ++lt;
      } else if (a[lt] > a[rt]) {
        lts.push_back(false);
        last = a[rt];
        --rt;
      } else {
        sameFlag = true;
        break;
      }
    } else {
      if (a[lt] > last) {
        lts.push_back(true);
        last = a[lt];
        ++lt;
      } else if (a[rt] > last) {
        lts.push_back(false);
        last = a[rt];
        --rt;
      } else {
        break;
      }
    }
  }
  if (sameFlag) {
    ori.assign(a + lt, a + rt + 1);
    rev = ori;
    reverse(rev.begin(), rev.end());
    int ltLast = last;
    int rtLast = last;
    int ltCnt = 0;
    int rtCnt = 0;
    for (int num : ori) {
      if (num > ltLast) {
        ++ltCnt;
        ltLast = num;
      } else {
        break;
      }
    }
    for (int num : rev) {
      if (num > rtLast) {
        ++rtCnt;
        rtLast = num;
      } else {
        break;
      }
    }
    if (ltCnt > rtCnt) {
      lts.insert(lts.end(), ltCnt, true);
    } else {
      lts.insert(lts.end(), rtCnt, false);
    }
  }
  printf("%u\n", lts.size());
  for (bool k : lts) {
    if (k) {
      printf("L");
    } else {
      printf("R");
    }
  }
  printf("\n");
}
