Problem: The only difference between problems C1 and C2 is that all values in input of problem C1 are distinct (this condition may be false for problem C2).

You are given a sequence a consisting of n integers. All these integers are distinct, each value from 1 to n appears in the sequence exactly once.

You are making a sequence of moves. During each move you must take either the leftmost element of the sequence or the rightmost element of the sequence, write it down and remove it from the sequence. Your task is to write down a strictly increasing sequence, and among all such sequences you should take the longest (the length of the sequence is the number of elements in it).

For example, for the sequence [2, 1, 5, 4, 3] the answer is 4 (you take 2 and the sequence becomes [1, 5, 4, 3], then you take the rightmost element 3 and the sequence becomes [1, 5, 4], then you take 4 and the sequence becomes [1, 5] and then you take 5 and the sequence becomes [1], the obtained increasing sequence is [2, 3, 4, 5]).

Input

The first line of the input contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of elements in a.

The second line of the input contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ n), where a_i is the i-th element of a. All these integers are pairwise distinct.

Output

In the first line of the output print k — the maximum number of elements in a strictly increasing sequence you can obtain.

In the second line print a string s of length k, where the j-th character of this string s_j should be 'L' if you take the leftmost element during the j-th move and 'R' otherwise. If there are multiple answers, you can print any.

Examples

Input


5
2 1 5 4 3


Output


4
LRRR


Input


7
1 3 5 6 7 4 2


Output


7
LRLRLLL


Input


3
1 2 3


Output


3
LLL


Input


4
1 2 4 3


Output


4
LLRL

Note

The first example is described in the problem statement.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
using namespace std;
#pragma GCC optimize("-O3")
using l = long;
using ll = long long;
using ld = long double;
const ll mod = 1000000007;
const ll INF = 1000000000000000000;
const ll rk = 256;
const ld PI = 3.141592653589793;
using namespace std;
ll inpt() {
  ll TemporaryVariable;
  cin >> TemporaryVariable;
  return TemporaryVariable;
}
vector<string> splitstring(string str) {
  stringstream ss(str);
  vector<string> s;
  string word;
  while (ss >> word) {
    s.push_back(word);
  }
  return s;
}
bool isPrime(int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
vector<int> SieveOfEratosthenes(int n) {
  vector<int> prm;
  bool prime[n + 1];
  memset(prime, true, sizeof(prime));
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
  for (int p = 2; p <= n; p++)
    if (prime[p]) prm.push_back(p);
  return prm;
}
ll gcd(ll a, ll b, ll x, ll y) {
  if (!a) return b;
  ll g = gcd(b % a, a, x, y);
  x = y - (b / a) * x;
  y = x;
  return g;
}
bool cmp(pair<ll, ll> p1, pair<ll, ll> p2) { return p1.second <= p2.second; }
ll power(int x, int i) {
  ll res = 1;
  for (__typeof(i) j = (0) - ((0) > (i)); j != (i) - ((0) > (i));
       j += 1 - 2 * ((0) > (i))) {
    res *= x;
  }
  return res;
}
vector<pair<ll, ll>> findSubArrays(vector<ll> arr, ll n) {
  unordered_map<ll, vector<ll>> map;
  vector<pair<ll, ll>> out;
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    sum += arr[i];
    if (sum == 0) out.push_back(make_pair(0, i));
    if (map.find(sum) != map.end()) {
      vector<ll> vector = map[sum];
      for (auto it = vector.begin(); it != vector.end(); it++) {
        out.push_back(make_pair(*it + 1, i));
      }
    }
    map[sum].push_back(i);
  }
  return out;
}
int greatestDigit(ll n) {
  ll s = 0;
  while (n) {
    s = max(s, n % 10);
    n /= 10;
  }
  return s;
}
ll nCr[1001][1001];
void precompute() {
  for (__typeof(1001) i = (0) - ((0) > (1001)); i != (1001) - ((0) > (1001));
       i += 1 - 2 * ((0) > (1001))) {
    for (__typeof(1001) j = (0) - ((0) > (1001)); j != (1001) - ((0) > (1001));
         j += 1 - 2 * ((0) > (1001))) {
      nCr[i][j] = 0;
    }
    nCr[i][0] = 1;
  }
  for (__typeof(1001) i = (1) - ((1) > (1001)); i != (1001) - ((1) > (1001));
       i += 1 - 2 * ((1) > (1001))) {
    for (__typeof(i + 1) j = (1) - ((1) > (i + 1));
         j != (i + 1) - ((1) > (i + 1)); j += 1 - 2 * ((1) > (i + 1))) {
      nCr[i][j] = (nCr[i - 1][j] + nCr[i - 1][j - 1]) % mod;
    }
  }
}
ll fact(ll n) {
  if (n == 1) return 1;
  return n * fact(n - 1);
}
string LCSubStr(string X, string Y) {
  int m = X.length();
  int n = Y.length();
  int result = 0;
  int end;
  int len[2][n];
  int currRow = 0;
  for (int i = 0; i <= m; i++) {
    for (int j = 0; j <= n; j++) {
      if (i == 0 || j == 0) {
        len[currRow][j] = 0;
      } else if (X[i - 1] == Y[j - 1]) {
        len[currRow][j] = len[1 - currRow][j - 1] + 1;
        if (len[currRow][j] > result) {
          result = len[currRow][j];
          end = i - 1;
        }
      } else {
        len[currRow][j] = 0;
      }
    }
    currRow = 1 - currRow;
  }
  if (result == 0) {
    return "";
  }
  return X.substr(end - result + 1, result);
}
void update(ll &x, ll y) {
  if (y == 0) return;
  if (x == 0) x = y;
  x = min(x, y);
}
ll ceil(ll a, ll b) {
  if (a % b) return a / b + 1;
  return a / b;
}
bitset<1000006> siv;
vector<ll> prime;
void sieve() {
  siv[0] = siv[1] = 1;
  prime.push_back(2);
  for (int i = 4; i <= 1000006; i += 2) siv[i] = 1;
  int sqrtn = sqrt(1000006);
  for (int i = 3; i <= sqrtn; i += 2) {
    if (siv[i] == 0) {
      for (int j = i * i; j <= 1000006; j += 2 * i) siv[j] = 1;
    }
  }
  for (int i = 3; i <= 1000006; i += 2)
    if (siv[i] == 0) prime.push_back(i);
}
int factorize(int n) {
  int ret = 1;
  int sqrtn = sqrt(n);
  for (int i = 0; i < prime.size() && prime[i] <= sqrtn; i++) {
    if (n % prime[i] == 0) {
      int cnt = 0;
      while (n % prime[i] == 0) {
        n /= prime[i];
        cnt++;
      }
      if (cnt % 2) ret *= prime[i];
      sqrtn = sqrt(n);
    }
  }
  if (n != 1) {
    ret *= n;
  }
  return ret;
}
ll exponentiation(ll base, ll exp) {
  if (exp == 0) return 1;
  if (exp == 1) return base % 1000000007;
  ll t = exponentiation(base, exp / 2);
  t = (t * t) % 1000000007;
  if (exp % 2 == 0)
    return t;
  else
    return ((base % 1000000007) * t) % 1000000007;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ll n;
  cin >> n;
  vector<ll> a(n);
  for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
       i += 1 - 2 * ((0) > (n)))
    cin >> a[i];
  ll lo = 0, hi = n - 1, tmp = INT_MIN;
  string res = "";
  while (lo <= hi) {
    if (a[lo] < a[hi] && a[lo] > tmp) {
      res += 'L';
      tmp = a[lo];
      lo++;
    } else if (a[hi] > tmp) {
      res += 'R';
      tmp = a[hi];
      hi--;
    } else if (a[lo] > tmp) {
      res += 'L';
      tmp = a[lo];
      lo++;
    } else
      break;
  }
  cout << res.length() << '\n';
  cout << res;
  cerr << "Time : " << 1000 * (ld)clock() / (ld)CLOCKS_PER_SEC << "ms\n";
  ;
  return 0;
}