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 PYTHON3):

Solution:
"""
- math -
from math import factorial
from math import gcd
from math import pi
large_p = 10**9 + 7
from itertools import accumulate # 累積和
from operator import mul
- other -
from collections import Counter
from itertools import combinations
from itertools import combinations_with_replacement
from itertools import permutations
from operator import itemgetter
from functools import reduce
- list -
from copy import deepcopy
from collections import deque
from heapq import heapify, heappop, heappush
- output -
p2d = lambda x: print(*x, sep="\n")
p2line = lambda x: print(*x, sep=" ")
print(*list1, sep="\n")
- input -
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
= map(int, input().split())
= [tuple(map(int, input().split())) for _ in range(n)]
m = map(int, read().split()) /ab = zip(m, m) /for a, b in ab:
ps = [line.split() for line in readlines()] # inputの最後まで読んでしまうので注意。
n, k, *h = map(int, read().split())
- run -
sys.setrecursionlimit(10**6)
from time import sleep
"""
#ATC06

import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import deque
def main():
    n = int(input())
    nums = deque(list(map(int, input().split())))
    ri = 0
    rs = []
    rs.append('D')
    t1 = 0
    if n == 1:
        print(1)
        print('L')
        sys.exit()

    while nums:
        if rs[-1] == 'L':
            l = nums.popleft()
        elif rs[-1] == 'R':
            r = nums.pop()
        elif rs[-1] == 'D':
            l = nums.popleft()
            r = nums.pop()
        #print(t1, l, r)
        if t1 < min(l, r):
            t1 = min(l, r)
            ri += 1
            rs += 'L' if l < r else 'R'
        elif t1 < max(l, r):
            t1 = max(l, r)
            ri += 1
            rs += 'L' if l > r else 'R'
        else:
            break
    if rs[-1] == 'L' and t1 < r:
        ri += 1
        rs += 'L'
    elif rs[-1] == 'R' and t1 < l:
        ri += 1
        rs += 'L'
    print(ri)
    print("".join(rs[1:]))

if __name__ == '__main__':
    main()

"""
def main():
    n = int(input())
    nums = deque(list(map(int, input().split())))
    ri = 0
    rs = ""
    t1 = 0
    while nums:
        nn = min(nums[0], nums[-1])
        nnmax = max(nums[0], nums[-1])

        if t1 < nn:
            t1 = nn
            ri += 1
            if nums[0] < nums[-1]:
                rs += "L"
                nums.popleft()
            else:
                rs += "R"
                nums.pop()
        elif t1 < nnmax:
            t1 = nnmax
            ri += 1
            if nums[0] < nums[-1]:
                rs += "R"
                nums.pop()
            else:
                rs += "L"
                nums.popleft()
        else:
            break
    print(ri)
    print(rs)

"""