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.math.*;
import java.util.*;

// author : Multi-Thread

public class Main {
	static int INF = (int) 1e9 + 7;

	public static void main(String[] args) {
//		int test = fs.nextInt();
		int test = 1;
		for (int cases = 0; cases < test; cases++) {
			solve();
		}

	}

	static void solve() {
		int n = fs.nextInt();
		ArrayDeque<Integer> dq = new ArrayDeque<Integer>();
		for (int i = 0; i < n; i++) {
			dq.add(fs.nextInt());
		}
		StringBuilder ans = new StringBuilder();
		ArrayList<Integer> ss = new ArrayList<>();
		while (dq.size() != 0) {
			int last = getLast(ss);
			int a = dq.peekFirst();
			int b = dq.peekLast();
			if (a <= last && b <= last) {
				break;
			} else if (a > last && b > last) {
				if (a == b) {
					ArrayList<Integer> part1 = new ArrayList<Integer>();
					ArrayList<Integer> part2 = new ArrayList<Integer>();
					for (Integer integer : dq) {
						if (part1.isEmpty()) {
							part1.add(integer);
							continue;
						}
						int ll = getLast(part1);
						if (integer > ll) {
							part1.add(integer);
						} else {
							break;
						}
					}
					Iterator<Integer> it = dq.descendingIterator();
					while (it.hasNext()) {
						int integer = it.next();
						if (part2.isEmpty()) {
							part2.add(integer);
							continue;
						}
						int ll = getLast(part2);
						if (integer > ll) {
							part2.add(integer);
						} else {
							break;
						}
					}
					if (part1.size() > part2.size()) {
						ans.append("L".repeat(part1.size()));
					} else {
						ans.append("R".repeat(part2.size()));
					}
					break;
				} else if (a < b) {
					ans.append("L");
					dq.removeFirst();
					ss.add(a);
				} else if (b < a) {
					ans.append("R");
					dq.removeLast();
					ss.add(b);
				}
			} else if (a > last) {
				dq.removeFirst();
				ss.add(a);
				ans.append("L");
			} else {
				dq.removeLast();
				ss.add(b);
				ans.append("R");
			}
		}
		System.out.println(ans.length());
		System.out.println(ans.toString());

	}

	static int getLast(ArrayList<Integer> ss) {
		return ss.isEmpty() ? -1 : ss.get(ss.size() - 1);
	}

	static int power(int x, int y, int p) {
		int res = 1;
		x = x % p;
		if (x == 0)
			return 0;
		while (y > 0) {
			if ((y & 1) == 1)
				res = (res * x) % p;
			y = y >> 1;
			x = (x * x) % p;
		}
		return res;
	}

	static void intSort(int[] ar, boolean reverse) {
		ArrayList<Integer> al = new ArrayList<Integer>();
		for (int i : ar)
			al.add(i);
		Collections.sort(al);
		if (reverse) {
			for (int i = 0; i < ar.length; i++)
				ar[i] = al.get(ar.length - i - 1);
		} else {
			for (int i = 0; i < ar.length; i++)
				ar[i] = al.get(i);
		}
	}

	static void longSort(long[] ar, boolean reverse) {
		ArrayList<Long> al = new ArrayList<Long>();
		for (long i : ar)
			al.add(i);
		Collections.sort(al);
		if (reverse) {
			for (int i = 0; i < ar.length; i++)
				ar[i] = al.get(ar.length - i - 1);
		} else {
			for (int i = 0; i < ar.length; i++)
				ar[i] = al.get(i);
		}
	}

	static void sieve() {
		boolean prime[] = new boolean[101];
		Arrays.fill(prime, true);
		prime[1] = false;
		for (int i = 2; i * i <= prime.length - 1; i++) {
			for (int j = i * i; j <= prime.length - 1; j += i) {
				prime[j] = false;
			}
		}
	}

	public static int[] radixSort(int[] f) {
		return radixSort(f, f.length);
	}

	public static int[] radixSort(int[] f, int n) {
		int[] to = new int[n];
		{
			int[] b = new int[65537];
			for (int i = 0; i < n; i++)
				b[1 + (f[i] & 0xffff)]++;
			for (int i = 1; i <= 65536; i++)
				b[i] += b[i - 1];
			for (int i = 0; i < n; i++)
				to[b[f[i] & 0xffff]++] = f[i];
			int[] d = f;
			f = to;
			to = d;
		}
		{
			int[] b = new int[65537];
			for (int i = 0; i < n; i++)
				b[1 + (f[i] >>> 16)]++;
			for (int i = 1; i <= 65536; i++)
				b[i] += b[i - 1];
			for (int i = 0; i < n; i++)
				to[b[f[i] >>> 16]++] = f[i];
			int[] d = f;
			f = to;
			to = d;
		}
		return f;
	}

	static class Pair {
		int first, second;

		public Pair(int first, int second) {
			this.first = first;
			this.second = second;
		}

		public String toString() {
			return "[" + first + "," + second + "]";
		}
	}

	static class LongPair {
		long first;
		long second;

		LongPair(long a, long b) {
			this.first = a;
			this.second = b;
		}

		public String toString() {
			return "[" + first + "," + second + "]";
		}
	}

	static void primeFactors(int n) {
		while (n % 2 == 0) {
			System.out.print(2 + " ");
			n /= 2;
		}
		for (int i = 3; i <= Math.sqrt(n); i += 2) {
			while (n % i == 0) {
				System.out.print(i + " ");
				n /= i;
			}
		}
		if (n > 2)
			System.out.print(n);
	}

	static boolean isPrime(long n) {
		if (n <= 1)
			return false;
		if (n <= 3)
			return true;
		if (n % 2 == 0 || n % 3 == 0)
			return false;
		long sq = (long) Math.sqrt(n);
		for (int i = 5; i <= sq; i = i + 6)
			if (n % i == 0 || n % (i + 2) == 0)
				return false;

		return true;
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	static 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]);
			}
		}

		public void println() {
			writer.print("\n");
		}

		public void printLine(Object... objects) {
			print(objects);
			writer.println();
		}

		public void close() {
			writer.close();
		}

		public void flush() {
			writer.flush();
		}

	}

	private static final FastReader fs = new FastReader();
	private static final OutputWriter op = new OutputWriter(System.out);
}