import java.io.*; import java.util.*; class Main { public static void main(String args[])throws Exception { BufferedReader bu=new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw=new PrintWriter(System.out); int n=Integer.parseInt(bu.readLine()); String s[]=bu.readLine().split(" "); int a[]=new int[n],b[]=new int[n],i; for(i=0;i fin=new ArrayList<>(); Deque q=new LinkedList<>(); int ans=0; for(i=0;ib[i] && a[j]>b[j] && b[j]<=a[j-1]))) q.addLast(j++); if(a[i]<=b[i]) while(!q.isEmpty()) fin.add(q.removeLast()); else while(!q.isEmpty()) fin.add(q.removeFirst()); i=j-1; } pw.append(ans+"\n"); for(int x:fin) { int l=a[x],r=b[x]; char c='R'; if(l>r) { l=b[x]; r=a[x]; c='L'; } while(l++