Once Bob saw a string. It contained so many different letters, that the letters were marked by numbers, but at the same time each letter could be met in the string at most 10 times. Bob didn't like that string, because it contained repeats: a repeat of length x is such a substring of length 2x, that its first half coincides character by character with its second half. Bob started deleting all the repeats from the string. He does it as follows: while it's possible, Bob takes the shortest repeat, if it is not unique, he takes the leftmost one, and deletes its left half and everything that is to the left of this repeat.

You're given the string seen by Bob. Find out, what it will look like after Bob deletes all the repeats in the way described above.

Input

The first input line contains integer n (1 ≤ n ≤ 105) — length of the string. The following line contains n space-separated integer numbers from 0 to 109 inclusive — numbers that stand for the letters of the string. It's guaranteed that each letter can be met in the string at most 10 times.

Output

In the first line output the length of the string's part, left after Bob's deletions. In the second line output all the letters (separated by a space) of the string, left after Bob deleted all the repeats in the described way.

Examples

Input

6
1 2 3 1 2 3


Output

3
1 2 3 


Input

7
4 5 6 5 6 7 7


Output

1
7 
	/*	/ ﾌﾌ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ム
		/ )\⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀  Y
		(⠀⠀| ( ͡° ͜ʖ ͡°）⠀⌒(⠀ ノ
		(⠀ ﾉ⌒ Y ⌒ヽ-く __／
		| _⠀｡ノ| ノ｡ |/
		(⠀ー '_人`ー ﾉ
		⠀|\ ￣ _人'彡ﾉ
		⠀ )\⠀⠀ ｡⠀⠀ /
		⠀⠀(\⠀ #⠀ /
		⠀/⠀⠀⠀/ὣ====================D-
		/⠀⠀⠀/⠀ \ \⠀⠀\
		( (⠀)⠀⠀⠀⠀ ) ).⠀)
		(⠀⠀)⠀⠀⠀⠀⠀( | /
		|⠀ /⠀⠀⠀⠀⠀⠀ | /
		[_] ⠀⠀⠀⠀⠀[___]                     */
	// Main Code at the Bottom
	import java.util.*;
	import java.lang.*;
	import java.io.*;
	import java.math.BigInteger; 
	public class Main {
		//Fast IO class
	    static class FastReader {
	        BufferedReader br; 
	        StringTokenizer st; 
	        public FastReader() {
	        	boolean env=System.getProperty("ONLINE_JUDGE") != null;
	        	if(!env) {
	        		try {
						br=new BufferedReader(new FileReader("src\\input.txt"));
					} catch (FileNotFoundException e) {
						e.printStackTrace();
					}
	        	}
	        	else 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 long MOD=1000000000+7;
	    //Euclidean Algorithm
	    static long gcd(long A,long B){
	    	return (B==0)?A:gcd(B,A%B);
	    }
	    //Modular Exponentiation
	    static long fastExpo(long x,long n){
	        if(n==0) return 1;
	        if((n&1)==0) return fastExpo((x*x)%MOD,n/2)%MOD;
	        return ((x%MOD)*fastExpo((x*x)%MOD,(n-1)/2))%MOD;
	    }
	    //Modular Inverse
	    static long inverse(long x) {
	    	return fastExpo(x,MOD-2);
	    }
	    //Prime Number Algorithm
	    static boolean isPrime(long n){
	        if(n<=1) return false;
	        if(n<=3) return true;
	        if(n%2==0 || n%3==0) return false;
	        for(int i=5;i*i<=n;i+=6) if(n%i==0 || n%(i+2)==0) return false;
	        return true;
	    }
	    //Reverse an array
	    static void reverse(int arr[],int l,int r){
	    	while(l<r) {
	    		int tmp=arr[l];
	    		arr[l++]=arr[r];
	    		arr[r--]=tmp;
	    	}
	    }
	    //Print array
	    static void print1d(int arr[]) {
	    	out.println(Arrays.toString(arr));
	    }
	    static void print2d(int arr[][]) {
	    	for(int a[]: arr) out.println(Arrays.toString(a));
	    }
	    // Pair
	    static class pair{
	    	int x,y;
	    	pair(int a,int b){
	    		this.x=a;
	    		this.y=b;
	    	}
	    	public boolean equals(Object obj) {
	    		if(obj == null || obj.getClass()!= this.getClass()) return false;
	            pair p = (pair) obj;
	            return (this.x==p.x && this.y==p.y);
	        }
	    	public int hashCode() {
	            return Objects.hash(x,y);
	        }
	    }
	    static FastReader sc=new FastReader();
	    static PrintWriter out=new PrintWriter(System.out);  
	    //Main function(The main code starts from here     
	    static int n,a[];
	    static long p=914846374,m1=1000000000+7,m2=1000000000+9,pow1[],pow2[],h1[],h2[];
	    static boolean isRepeat(int i,int j) {
	    	int len=2*(j-i);
	    	if(2*j-i>n) return false;
	    	long H1=(h1[j-1]-(i-1<0?0:h1[i-1])+m1)%m1,H2=(h2[j-1]-(i-1<0?0:h2[i-1])+m2)%m2;
	    	H1=(H1*pow1[n-i-1])%m1;H2=(H2*pow2[n-i-1])%m2;
	    	long G1=(h1[i+len-1]-h1[j-1]+m1)%m1,G2=(h2[i+len-1]-h2[j-1]+m2)%m2;
	    	G1=(G1*pow1[n-j-1])%m1;G2=(G2*pow2[n-j-1])%m2;
	    	if(H1==G1 && H2==G2) return true;
	    	return false;
	    }
	    public static void main (String[] args) throws java.lang.Exception {
	    	int test;
	    	test=1;
	    	//test=sc.nextInt();
	    	while(test-->0){
	    		n=sc.nextInt();a=new int[n];
	    		for(int i=0;i<n;i++) a[i]=sc.nextInt();
	    		pow1=new long[n];pow2=new long[n];h1=new long[n];h2=new long[n];
	    		pow1[0]=pow2[0]=1;
	    		for(int i=1;i<n;i++) {
	    			pow1[i]=((pow1[i-1]%m1)*(p%m1))%m1;
	    			pow2[i]=((pow2[i-1]%m2)*(p%m2))%m2;
	    		}
	    		h1[0]=h2[0]=a[0]+1;
	    		for(int i=1;i<n;i++) {
	    			h1[i]=(h1[i-1]%m1+(((a[i]+1)%m1)*pow1[i])%m1)%m1;
	    			h2[i]=(h2[i-1]%m2+(((a[i]+1)%m2)*pow2[i])%m2)%m2;
	    		}
	    		ArrayList<pair> res=new ArrayList<>();
	    		Integer sorted[]=new Integer[n];
	    		for(int i=0;i<n;i++) sorted[i]=i;
	    		Arrays.parallelSort(sorted,(x,y)->(a[x]!=a[y]?a[x]-a[y]:x-y));
	    		for(int i=0;i<n;i++) {
	    			int j=i+1;
	    			while(j<n && a[sorted[j]]==a[sorted[i]]) {
	    				if(isRepeat(sorted[i],sorted[j])) {
	    					res.add(new pair(sorted[i],sorted[j]));
	    				}
	    				j++;
	    			}
	    		}
	    		Collections.sort(res,(p1,p2)->(p1.y-p1.x==p2.y-p2.x?p1.x-p2.x:(p1.y-p1.x-p2.y+p2.x)));
	    		int idx=0;
	    		for(pair p: res) if(p.x>=idx)idx=Math.max(idx, p.y);
	    		out.println(n-idx);
	    		for(int i=idx;i<n;i++) out.print(a[i]+" ");
	    	}
	        out.flush();
	        out.close();
	    }
	}