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.io.*;
import java.util.concurrent.LinkedBlockingQueue;
public class Codechef
{   
    static String arr[];
    static ArrayList<Integer>graph[];
    static int size[];
    static boolean deleted[];
    static boolean vis[];
    static int MAX = 500001;
    static int a,b,n,maxa;
    static int cache[];
	public static void main (String[] args) throws java.lang.Exception
	{
	    InputReader input = new InputReader(System.in);
	     OutputWriter out = new OutputWriter(System.out);
	     // input = new Scanner(System.in);
	    int n = input.readInt();
	    int arr[] = new int[n];
	    for(int i =0;i<n;i++){
	        arr[i] = input.readInt();
	    }
	    int l =0;
	    int r = n-1;
	    int last =0;
	    int seq =0;
	    char c[] = new char[n];
	    if(arr[n-1]<arr[0]){
	        seq++;
	        c[0] = 'R';
	        r--;
	        last = arr[n-1];
	    }else{
	        seq++;
	        c[0] = 'L';
	        l++;
	        last = arr[0];
	    }
	    boolean ok = false;
	    int z =1;
	    while(l<=r){
	        int val1 = arr[l];
	        int val2 = arr[r];
	        int max = Math.max(val1,val2);
	        int min = Math.min(val1,val2);
	        ok = false;
	        if(min>last){
	            seq++;
	            ok = true;
	            last = min;
	            if(min == val1){
	                l++;
	                c[z++] = 'L';
	            }else{
	                r--;
	                c[z++] = 'R';
	            }
	       
	        }else if(max>last){
	            seq++;
	            ok = true;
	            last = max;
	            if(max == val1){
	                l++;
	                c[z++] = 'L';
	            }else{
	                r--;
	                c[z++] = 'R';
	            }
	        }
	       if(!ok)break;
 
	        
	    }
	    	System.out.println(seq);
	        for(int i =0;i<z;i++)System.out.print(c[i]);
	    
	    
	    
	      
	}
	public static void useB(int bit){
	    if(bit == 1)a = Math.min(a+1,maxa);
	    b--;
	} 
	public  static void useA(){
	    a--;
	}
	public static void centroid_decomposition(){
	    decompose(0);
	}
	public static void decompose(int v){
	    calculateSubtreeSize(v);
	    int centroid = findCentroid(v,size[v]);
	    System.out.print((centroid+1)+" ");
	    calculateSubtreeSize(centroid);
	    deleted[centroid] = true;
	    for(int child:graph[v]){
	        if(deleted[child])continue;
	        decompose(child);
	    }
	}
	public static int findCentroid(int v,int total){
	    for(int child:graph[v]){
	        if(vis[child] || deleted[child])continue;
	        if(size[child]>total/2){
	            findCentroid(child,size[child]);
	        }
	    }
	    return v;
	}
	public static void calculateSubtreeSize(int v){
	    size[v] = 1;
	    vis[v] = true;
	    for(int child:graph[v]){
	        if(vis[child] || deleted[v])continue;
	        calculateSubtreeSize(child);
	        size[v]+=size[child];
	    }
	}
}
class Query{
    String s = null;
    public Query(String s){
        this.s = s;
    }
}
class Node{
    int id,r,l;
    public Node(int r,int l,int id){
        this.r = r;
        this.l = l;
        this.id = id;
    }
}
 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 int readInt() {
			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 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 double readDouble() {
			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, readInt());
				}
				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, readInt());
					}
					if (c < '0' || c > '9') {
						throw new InputMismatchException();
					}
					m /= 10;
					res += (c - '0') * m;
					c = read();
				}
			}
			return res * sgn;
		}
		
		public long readLong() {
			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 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);
		}
	}
	
 class OutputWriter {
		private final PrintWriter writer;
		
		public OutputWriter(OutputStream outputStream) {
			writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
		}
		
		public OutputWriter(Writer writer) {
			this.writer = new PrintWriter(writer);
		}
		
		public void print(Object... objects) {
			for (int i = 0; i < objects.length; i++) {
				if (i != 0) {
					writer.print(' ');
				}
				writer.print(objects[i]);
			}
			writer.flush();
		}
		
		public void printLine(Object... objects) {
			print(objects);
			writer.println();
			writer.flush();
		}
		
		public void close() {
			writer.close();
		}
		
		public void flush() {
			writer.flush();
		}
	}
	   
//********************************************************************************************************************************
//////////////////////////////////NOTESSS//////////////////////////////////////////////////////////////////////
/*remember substring length you are dealing with take only those substrings
chain like pattern -> linked list (or) to from Arrays
finding degree can be done during input scanning itself(ok&=true:false flag trick)
longest subsquence can be solved in O(n) itself incase of consecutive numbers why try all subsequence go o dp[i-1]
(*******consecutive numberssssss*********)
initialize all global variables and collection ds
swapping changes the arr so make sure initialize with the original again(careful from where to start after swapping)
missing out character when comparing ==0 instead of =='0'
keep going until a condition and start off from first ****stack***
meet in the middle algo
one dfs call will tell u the dfs of all nodes
2d prefix array for max occurence of number in a range.also storing positions in case of duplicate numbers can
help bring down the complexity to o(N) and considering ranges based on positions
 
when u want to apply changes for a range PREFIX SUMS
want to know number of elements in  range use preifx sum (or)l,r pointer from a particular point
when u want to use binary search check if problem remains the same even after splitting to two parts
checking for range can be done using binary search i.e can this range stisfy a particular condition if so
include more elements to tha range from left to right or right to left depending on the problem
 
parity can also be checked to make elements equal(when making elements equal check what is allowed and what not
and how to achieve it what are the result sets after applying the allowed moves like add 1 add 2.....)
 
each step u want max range incase if its equal u select upon the condition---> what DS= ***PRIORITY QUEUE***
*/