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

Solution:
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
public class Solution{ 
    static InputReader sc;
    static PrintWriter wc;
     
    public static void main(String[] args) {
        sc=new InputReader(System.in);
        wc=new PrintWriter(System.out);
        int n=sc.nextInt();
        Deque<Integer> q=new LinkedList<Integer>();
        int i;
        for(i=0;i<n;i++){
            q.add(sc.nextInt());
        }
        int res=1;
        StringBuffer s=new StringBuffer();
        int max;
        if(q.peek()<q.peekLast()){
            max=q.peekFirst();
            q.removeFirst();
            s.append("L");
        }
        else if(q.peek()>q.peekFirst()){
            max=q.peekLast();
            q.removeLast();
            s.append("R");
        }
        else{
            max=-1;
            res=0;
        }
        while(true){
            if(q.size()==0) break;
            if(q.peekFirst()>q.peekLast()){
                if(max<q.peekLast()){
                    res++;
                    max=q.peekLast();
                    s.append("R");
                    q.removeLast();

                }
                else{
                    if(max<q.peekFirst()){
                        res++;
                        max=q.peekFirst();
                        s.append("L");
                        q.removeFirst();
                    }
                    else{
                        break;
                    }
                }
            }   
            else if(q.peekFirst()<q.peekLast()){
                if(max<q.peekFirst()){
                    res++;
                    max=q.peekFirst();
                    s.append("L");
                    q.removeFirst();
                }
                else{
                    if(max<q.peekLast()){
                        res++;
                        max=q.peekLast();
                        s.append("R");
                        q.removeLast();
                    }
                    else{
                        break;
                    }
                }
            }
            else if(max<q.peekFirst()){
                ArrayList<Integer> al=new ArrayList<>();
                while(q.size()>0){
                    al.add(q.peekFirst());
                    q.removeFirst();
                }
                int index=0,l=1,r=1;
                int len=al.size();
                int max1=al.get(0);
                index++;
                while(index<len&&al.get(index)>max1){
                    l++;
                    max1=al.get(index++);
                }
                index=len-2;
                max1=al.get(len-1);
                while(index>=0&&al.get(index)>max1){
                    r++;
                    max1=al.get(index--);
                }
                if(l>r){
                    res+=l;
                    while(l-->0){
                        s.append("L");
                    }
                    wc.println(res+"\n"+new String(s));
                    wc.close();
                    return;
                }
                else{
                    res+=r;
                    while(r-->0){
                        s.append("R");
                    }
                    wc.println(res+"\n"+new String(s));
                    wc.close();
                    return;
                }
            }
            else break;
        }
        wc.println(res+"\n"+new String(s));
        wc.close();
    }
    static class InputReader {
        
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;
        
        public InputReader(InputStream stream)
        {
            this.stream = stream;
        }
        
        public int read()
        {
            if (numChars==-1) 
                throw new InputMismatchException();
            
            if (curChar >= numChars)
            {
                curChar = 0;
                try 
                {
                    numChars = stream.read(buf);
                }
                catch (IOException e)
                {
                    throw new InputMismatchException();
                }
                
                if(numChars <= 0)               
                    return -1;
            }
            return buf[curChar++];
        }
     
        public String nextLine()
        {
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
        public int nextInt()
        {
            int c = read();
            
            while(isSpaceChar(c)) 
                c = read();
            
            int sgn = 1;
            
            if (c == '-') 
            {
                sgn = -1;
                c = read();
            }
            
            int res = 0;
            do 
            {
                if(c<'0'||c>'9') 
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c)); 
            
            return res * sgn;
        }
        
        public long nextLong() 
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') 
            {
                sgn = -1;
                c = read();
            }
            long res = 0;
            
            do 
            {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
                return res * sgn;
        }
        
        public double nextDouble() 
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') 
            {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') 
            {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') 
            {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) 
                {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }
        
        public String readString() 
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do 
            {
                res.appendCodePoint(c);
                c = read();
            } 
            while (!isSpaceChar(c));
            
            return res.toString();
        }
     
        public boolean isSpaceChar(int c) 
        {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
     
        public String next() 
        {
            return readString();
        }
        
        public interface SpaceCharFilter 
        {
            public boolean isSpaceChar(int ch);
        }
    }   
}