#include <bits/stdc++.h>
using namespace std;
struct comp {
  bool operator()(int a, int b) { return a > b; }
};
int main() {
  int n, data[200005];
  string ans = "";
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &data[i]);
  int l = 1, r = n, last = 0;
  while (l <= r && max(data[l], data[r]) > last) {
    if (l == r) {
      ans += "L";
      l++;
    } else if (data[l] != data[r]) {
      bool isLValid = (data[l] > last);
      bool isRValid = (data[r] > last);
      if (isLValid && (data[l] <= data[r] || !isRValid)) {
        last = data[l];
        l++;
        ans += "L";
      } else {
        last = data[r];
        r--;
        ans += "R";
      }
    } else {
      int fromL = 1, fromR = 1;
      for (int i = l + 1; i <= r; i++) {
        if (data[i - 1] < data[i])
          fromL++;
        else
          break;
      }
      for (int i = r - 1; i >= l; i--) {
        if (data[i] > data[i + 1])
          fromR++;
        else
          break;
      }
      if (fromL >= fromR)
        for (int i = 1; i <= fromL; i++) ans += "L";
      else
        for (int i = 1; i <= fromR; i++) ans += "R";
      break;
    }
  }
  cout << ans.size() << endl << ans << endl;
  return 0;
}
