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:
class Node:

    def __init__(self, data=None, prev_node=None, next_node=None):
        self.data = data
        self.prev = prev_node
        self.next = next_node
    def __repr__(self):
        return str(self.data)

    def __le__(self, other):
        if isinstance(other, Node):
            other = other.data
        return True if self.data <= other else False
    def __eq__(self, other):
        if isinstance(other, Node):
            other = other.data
        return True if self.data == other else False
    def __lt__(self, other):
        if isinstance(other, Node):
            other = other.data
        return True if self.data < other else False
    def __gt__(self, other):
        if isinstance(other, Node):
            other = other.data
        return True if self.data > other else False

    def __ge__(self, other):
        if isinstance(other, Node):
            other = other.data
        return True if self.data >= other else False

    def __ne__(self, other):
        if isinstance(other, Node):
            other = other.data
        return True if self.data != other else False
    

def catdog(iterable, reverse=False):
    new_catdog = CatDog()
    for item in iterable:
        if reverse:
            new_catdog.pushcat(item)
        else:
            new_catdog.pushdog(item)
    return new_catdog

def change_len(func, val):
        def wrapped(self, *args, **kwargs):
            out = func(self, *args, **kwargs)
            self.len += val
            return out
        return wrapped

def increment_len(func):
    return change_len(func, 1)

def decrement_len(func):
    return change_len(func, -1)

class CatDog:        
    def __init__(self, *items, reverse=False):
        self.cat = None
        self.dog = None
        self._cur = None
        self.len = 0
        
        for item in items:
            if reverse:
                self.pushcat(item)
            else:
                self.pushdog(item)
                 
    def __len__(self):
        return self.len
            
    def __iter__(self):
        self._cur = self.cat
        return self

    def __next__(self):
        if self._cur is None:
            self._cur = self.cat
            raise StopIteration
        else:
            data = self._cur.data
            self._cur = self._cur.next
            return data

    def __repr__(self):
        items = ', '.join(map(str, self))
        in_brackets = f'[{items}]'
        return in_brackets

    def showcat(self):
        return self.cat.data

    def showdog(self):
        return self.dog.data
    @increment_len
    def pushdog(self, data):
        new = Node(data=data)
        old = self.dog
        if old is None:
            self.dog = new
            self.cat = new
        else:
            self._chain(old, new)
            self.dog = new

    @increment_len    
    def pushcat(self, data):
        new = Node(data=data)
        old = self.cat
        if old is None:
            self.cat = new
            self.dog = new
        else:
            self._chain(new, old)
            self.cat = new

    @decrement_len
    def popcat(self):
        if self.is_empty():
            raise Exception
        cat = self.cat
        if cat.next is not None:
            cat.next.prev = None
        else:
            self.dog = None
        self.cat = cat.next
        return cat.data

    @decrement_len
    def popdog(self):
        if self.is_empty():
            raise Exception
        dog = self.dog
        if dog.prev is not None:
            dog.prev.next = None
        else:
            self.cat = None
        self.dog = dog.prev
        return dog.data
        
    def is_empty(self):
        return False if self.len else True

    def _chain(self, first, second):
        first.next = second
        second.prev = first
        
def main():
    n = int(input())
    A = catdog(map(int, input().split()))
    B = ''
    last = 0
    cat, dog = A.cat, A.dog
    while not A.is_empty() and (cat > last or dog > last):        
        if cat > dog and dog > last:
            last = A.popdog()
            B+='R'
        elif cat < dog and cat > last:
            last = A.popcat()
            B+='L'
        elif cat == dog and cat is not dog:
            break
        elif cat > last:
            last = A.popcat()
            B+='L'
        elif dog > last:
            last = A.popdog()
            B+='R'
        cat, dog = A.cat, A.dog
    else:
        print(len(B))
        print(B)
        return

    cntcat = 1
    pcat = cat
    cat = cat.next    
    while cat is not None and cat > pcat:
        pcat = cat
        cat = cat.next
        cntcat+=1
    cntdog = 1
    pdog = dog
    dog = dog.prev
    while dog is not None and dog > pdog:
        pdog = dog
        dog = dog.prev
        cntdog+=1
    if cntcat > cntdog:
        B += 'L'*cntcat
    else:
        B += 'R'*cntdog
    print(len(B))
    print(B)

main()