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.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import static java.lang.Math.*;
public class Main
{
    static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }
    static class Pair implements Comparable<Pair> {
        int x,y,ind;

        public Pair(int x, int y,int ind) {
            this.x = x;
            this.y = y;
            this.ind=ind;
        }
        public int compareTo(Pair o) {
            if(x!=o.x)
                return x-o.x;
            return this.y - o.y;
        }
        public int hashCode() {
            return (int)(1L*1000000000*x + y)%1000000007;
        }
        public boolean equals(Object o) {
            if(o instanceof Pair) {
                Pair other = (Pair)o;
                return other.hashCode()==this.hashCode();
            }
            else return false;
        }
        public String toString(){
            return x+" "+y;
        }
    }
    static Scanner sc = new Scanner(System.in);
    //static Reader sc = new Reader();
    static StringBuilder sb = new StringBuilder();
    static PrintWriter pw = new PrintWriter(System.out,true);
    static int n,arr[],brr[];
    public static void main(String[] args) throws IOException {
        //Code start from here
        n = sc.nextInt();
        //LinkedList<Integer> list = new LinkedList<>();
        int arr[] = new int[n];
        for (int i = 0; i < n; i++)
            arr[i] = (sc.nextInt());
        int i = 0, j = n - 1, prev = 0,c=0;
        while(j>=i) {
            if(i==j) {
                if(arr[i]>prev) {
                    sb.append("R");
                    c++;
                }break;
            }
            if(arr[i]<arr[j]) {
                if(arr[i]>prev) {
                    sb.append("L");c++;
                    prev = arr[i];
                    i++;
                }
                else if(arr[j] > prev) {
                    sb.append("R");c++;
                    prev = arr[j];
                    j--;
                }
            }
            if(arr[j]<arr[i]) {
                if(arr[j] > prev) {
                    sb.append("R");c++;
                    prev = arr[j];
                    j--;
                }
                else if(arr[i]>prev) {
                    sb.append("L");c++;
                    prev = arr[i];
                    i++;
                }
            }
            if(arr[i]<prev && arr[j]<prev)
                break;
        }
        System.out.println(c);
        pw.println(sb);
        pw.flush();
        pw.close();
    }
    static void dfs(int left,int right,Set<Integer> set,String str) {
        if(set.size()==n-1) {
            System.out.println(str);
            System.exit(0);
        }
       // System.out.println(str);
        for(int i =1;i<n-1;i++) {
            if(!set.contains(i)) {
                if(left==arr[i]) {
                    set.add(i);
                    dfs(brr[i],right,set,brr[i]+" "+str);
                    set.remove(i);
                }
                if(left==brr[i]) {
                    set.add(i);
                    dfs(arr[i],right,set,arr[i]+" "+str);
                    set.remove(i);
                }
                if(right==arr[i]) {
                    set.add(i);
                    dfs(left,brr[i],set,str+" "+brr[i]);
                    set.remove(i);
                }
                if(right==brr[i]) {
                    set.add(i);
                    dfs(left,arr[i],set,str+" "+arr[i]);
                    set.remove(i);
                }
            }
        }
    }
}