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

import static java.lang.Math.*;
import static java.util.Arrays.fill;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.sort;

public class Main {
	public static void main(String[] args) throws IOException {
		new Thread(null, new Runnable() {
			public void run() {
				try {
					try {
						if (new File("input.txt").exists())
							System.setIn(new FileInputStream("input.txt"));
					} catch (SecurityException e) {}
					new Main().run();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}, "1", 1L << 24).start(); 
	}

	Random rnd = new Random(777L);
	int BASE = BigInteger.probablePrime(17, rnd).intValue();
	Map<Integer, Integer> code;
	
	int N;
	int[] a;
	MultiList ml;
	
	int[] hash;
	int[] pow;
	
	void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		
		N = nextInt();
		code = new HashMap<Integer, Integer>(N);
		ml = new MultiList(N, N);
		a = new int [N];
		for (int i = 0; i < N; i++) {
			a[i] = nextInt();
			ml.add(a[i], i);
			code.put(a[i], rnd.nextInt());
		}
		
		hash = new int [N + 1];
		pow = new int [N + 1]; pow[0] = 1;
		
		for (int i = 1; i <= N; i++) {
			hash[i] = hash[i - 1] * BASE + code.get(a[i - 1]);
			pow[i] = pow[i - 1] * BASE;
		}
		
		int lastLen = Integer.MAX_VALUE / 2;
		int lastCut = -1;
		
		int ans = 0;
		for (int i = 0; i < N; i++) {
			for (int t = ml.head[ml.index(a[i])]; t != 0; t = ml.next[t]) {
				int j = ml.pos[t];
				if (repeat(j, i)) {
					int len = i - j;
					if (lastLen > len || lastLen <= len && lastCut <= j) {
						lastLen = len;
						lastCut = ans = i;
					}
				}
			}
		}
		
		out.println(N - ans);
		for (int i = ans; i < N; i++) {
			if (i > ans) out.print(' ');
			out.print(a[i]);
		}
		out.println();
		
		out.close();
	}
	
	boolean repeat(int l, int m) {
		if (l >= m) return false;
		int r = m + m - l - 1;
		if (r >= N) return false;
		return hash(l, m - 1) * pow[m - l] == hash(m, r);
	}

	int hash(int l, int r) {
		return hash[r + 1] - hash[l];
	}

	class MultiList {
		int[] head;
		int[] next;
		int[] pos;
		int cnt = 1;
		Map<Integer, Integer> map;
		
		MultiList(int hNum, int size) {
			head = new int [hNum];
			next = new int [size + 1];
			pos  = new int [size + 1];
			map  = new HashMap<Integer, Integer>(hNum);
		}
		
		int index(int h) {
			if (!map.containsKey(h))
				map.put(h, map.size());
			return map.get(h);
		}
		
		void add(int h, int p) {
			h = index(h);
			next[cnt] = head[h];
			pos[cnt] = p;
			head[h] = cnt++;
		}
	}
	
	/*************************************************************** 
	 * Utility
	 **************************************************************/
	long b2mb(long b) {
		return b >> 20;
	}
	
	void checkMemory() {
		System.err.println(b2mb(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) + "/" + b2mb(Runtime.getRuntime().totalMemory()) + " MB");
	}
	
	/*************************************************************** 
	 * Input 
	 **************************************************************/
	BufferedReader in;
	PrintWriter out;
	StringTokenizer st = new StringTokenizer("");
	
	String nextToken() throws IOException {
		while (!st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}
	
	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}
	
	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}
	
	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
	
	String nextLine() throws IOException {
		st = new StringTokenizer("");
		return in.readLine();
	}
	
	boolean EOF() throws IOException {
		while (!st.hasMoreTokens()) {
			String s = in.readLine();
			if (s == null)
				return true;
			st = new StringTokenizer(s);
		}
		return false;
	}
}
