#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  string ans = "";
  int l = 0, r = n - 1;
  while (true) {
    int ma = 0;
    bool f = 0;
    while ((v[l] != v[r]) && l < r) {
      if (v[l] < v[r] && v[l] > ma) {
        l++;
        ans += 'L';
        ma = v[l - 1];
      } else if (v[l] < v[r] && v[r] > ma) {
        r--;
        ans += 'R';
        ma = v[r + 1];
      } else if (v[r] < v[l] && v[r] > ma) {
        r--;
        ans += 'R';
        ma = v[r + 1];
      } else if (v[r] < v[l] && v[l] > ma) {
        l++;
        ans += 'L';
        ma = v[l - 1];
      } else {
        f = 1;
        break;
      }
    }
    if (l == r && v[l] > ma) ans += 'R';
    if (l >= r || f) break;
    int r1 = r, l1 = l, rcnt = 0, lcnt = 0;
    int maa = ma;
    while (v[r1] > maa) {
      rcnt++;
      maa = max(maa, v[r1]);
      r1--;
    }
    maa = ma;
    while (v[l1] > maa) {
      lcnt++;
      maa = max(maa, v[l1]);
      l1++;
    }
    if (rcnt > lcnt) {
      for (int i = 0; i < rcnt; i++) ans += "R";
    } else {
      for (int i = 0; i < lcnt; i++) ans += "L";
    }
    break;
  }
  cout << ans.size() << endl << ans << endl;
}
