#include <bits/stdc++.h>
using namespace std;
int n, ans, k, d, cnt1, cnt2, l, r;
int a[200050];
struct node {
  int x, b;
};
node s[200050];
int main() {
  k = 1;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i]);
  }
  l = 1, r = n, s[0].x = 0;
  d = 0;
  while ((a[l] > s[d].x || a[r] > s[d].x) && l <= r) {
    if (a[l] != a[r]) {
      if (a[l] < a[r] && a[l] > s[d].x || (a[l] > a[r] && a[r] <= s[d].x)) {
        d++;
        s[d].x = a[l];
        s[d].b = 0;
        ans = d;
        l++;
        continue;
      }
      if (a[r] > s[d].x) {
        d++;
        s[d].x = a[r];
        s[d].b = 1;
        ans = d;
        r--;
        continue;
      }
    }
    if (a[l] == a[r] && l != r) {
      k = 0;
      cnt1 = 0, cnt2 = 0;
      for (int j = l; j <= r - 1; ++j) {
        if (a[j + 1] > a[j])
          cnt1++;
        else
          break;
      }
      for (int j = r; j >= l + 1; --j) {
        if (a[j] < a[j - 1])
          cnt2++;
        else
          break;
      }
      if (cnt1 >= cnt2) {
        ans += cnt1 + 1;
        printf("%d\n", ans);
        for (int j = 1; j <= ans - cnt1 - 1; ++j) {
          if (s[j].b == 0)
            printf("L");
          else
            printf("R");
        }
        for (int j = 0; j < cnt1 + 1; ++j) {
          printf("L");
        }
        break;
      }
      if (cnt1 < cnt2) {
        ans += cnt2 + 1;
        printf("%d\n", ans);
        for (int j = 1; j <= ans - cnt2 - 1; ++j) {
          if (s[j].b == 0)
            printf("L");
          else
            printf("R");
        }
        for (int j = 0; j < cnt2 + 1; ++j) {
          printf("R");
        }
        break;
      }
    }
    if (l == r && k == 1) {
      ans++;
      s[ans].b = 1;
      break;
    }
  }
  if (k == 1) {
    printf("%d\n", ans);
    for (int i = 1; i <= ans; ++i) {
      if (s[i].b == 0)
        printf("L");
      else
        printf("R");
    }
  }
  return 0;
}
