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;
long long prr[] = {2,   3,   5,   7,   11,  13,  17,  19,  23,  29,  31,  37,
                   41,  43,  47,  53,  59,  61,  67,  71,  73,  79,  83,  89,
                   97,  101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151,
                   157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223,
                   227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281,
                   283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359,
                   367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433,
                   439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499};
long long powmod(long long a, long long b, long long modulo) {
  if (b == 0 || a == 1) return 1;
  long long half = powmod(a, (b / 2), modulo) % modulo;
  long long full = (half * half) % modulo;
  if (b % 2) return (full * a) % modulo;
  return full % modulo;
}
long long invmod(long long a, long long modulo) {
  long long check = powmod(a, modulo - 2, modulo) % modulo;
  return check;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
bool isPrime[5000005];
int prime[5000005];
void sieve(long long N) {
  for (long long i = 0; i <= N; ++i) {
    isPrime[i] = true;
  }
  isPrime[0] = false;
  isPrime[1] = false;
  for (int i = 2; i * i <= N; ++i) {
    if (isPrime[i] == true) {
      for (int j = i * i; j <= N; j += i) isPrime[j] = false;
    }
  }
  int j = 0;
  for (int i = 2; i <= N; i++) {
    if (isPrime[i]) {
      prime[j] = i;
      j++;
    }
  }
}
bool palindrome(string s) {
  for (long long i = 0; i < s.length() / 2; i++) {
    if (s[i] != s[s.length() - i - 1]) return 0;
  }
  return 1;
}
void solve() {
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  string res = "";
  int l = 0;
  int r = n - 1;
  int val = 0;
  if (arr[l] < arr[r]) {
    res += 'L';
    val = arr[l];
    l++;
  } else {
    res += 'R';
    val = arr[r];
    r--;
  }
  while (l <= r) {
    int temp1 = max(arr[l], arr[r]);
    int temp2 = min(arr[r], arr[l]);
    if (val > temp1) break;
    if (arr[l] < arr[r]) {
      if (arr[l] > val) {
        res += 'L';
        val = arr[l];
        l++;
      } else {
        res += 'R';
        val = arr[r];
        r--;
      }
    } else {
      if (arr[r] > val) {
        res += 'R';
        val = arr[r];
        r--;
      } else {
        res += 'L';
        val = arr[l];
        l++;
      }
    }
  }
  int len = res.length();
  cout << len << "\n";
  cout << res << "\n";
}
int main() {
  clock_t start, end;
  start = clock();
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  solve();
  end = clock();
  double time = double(end - start) / (double)(CLOCKS_PER_SEC);
  return 0;
}