#include <bits/stdc++.h>
using namespace std;
vector<int> a;
vector<char> k, ans;
void func(int p, int l, int r) {
  if (a[l] > a[p] && (a[l] <= a[r] || a[r] <= a[p])) {
    k.push_back('L');
    if (k.size() > ans.size()) ans = k;
    if (r - l >= 1) func(l, l + 1, r);
    k.pop_back();
  }
  if (a[r] > a[p] && (a[r] <= a[l] || a[l] <= a[p])) {
    k.push_back('R');
    if (k.size() > ans.size()) ans = k;
    if (r - l >= 1) func(r, l, r - 1);
    k.pop_back();
  }
}
void solve() {
  a.clear();
  ans.clear();
  k.clear();
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int c;
    cin >> c;
    a.push_back(c);
  }
  if (n == 1) {
    cout << 1 << endl << "L" << endl;
    return;
  }
  k.push_back('L');
  if (k.size() > ans.size()) ans = k;
  func(0, 1, a.size() - 1);
  k.pop_back();
  k.push_back('R');
  func(a.size() - 1, 0, a.size() - 2);
  k.pop_back();
  cout << ans.size() << endl;
  ;
  for (int i = 0; i < ans.size(); i++) cout << ans[i];
  cout << endl << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  int n = 1;
  while (n--) solve();
  return 0;
}
