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.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.HashMap;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.TreeSet;
import java.util.AbstractCollection;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Zyflair Griffane
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		PandaScanner in = new PandaScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}
}

class Task {
    public void solve(int testNumber, PandaScanner in, PrintWriter out) {
        in.nextLine();
        int[] originalArray = ParseUtil.parseIntArray(in.nextLine());
        int[] arr = ArrayUtil.compress(originalArray);
        int distinct = ArrayUtil.max(arr) + 1;
        int cnt[] = new int[distinct];
        int idx[][] = new int[distinct][10];
        SuffixArray sa = new SuffixArray(arr);
        PriorityQueue<Repeat> repeats = new PriorityQueue<>();
        for (int i = 0; i < arr.length; i++) {
            int curr = arr[i];
            int currIdx = cnt[curr];
            for (int j = 0; j < currIdx; j++) {
                int k = idx[curr][j];
                if (sa.lcp(k, i) >= i - k) {
                    repeats.add(new Repeat(k, i - k));
                }
            }
            idx[curr][currIdx] = i;
            cnt[curr]++;
        }
        int left = 0;
        while (!repeats.isEmpty()) {
            Repeat r = repeats.poll();
            if (r.idx >= left) {
                left = r.idx + r.w;
            }
        }
        out.println(arr.length - left);
        for (int i = left; i < arr.length; i++) {
            out.print(originalArray[i]);
            out.print(" ");
        }
    }
    public class Repeat implements Comparable<Repeat> {
        int idx;
        int w;
        public Repeat(int idx, int w) {
            this.idx = idx;
            this.w = w;
        }
        public int compareTo(Repeat o) {
            if (w != o.w) {
                return w - o.w;
            }
            return idx - o.idx;
        }
    }
}

class PandaScanner {
    public BufferedReader br;
    public InputStream in;

    public PandaScanner(InputStream in) {
        br = new BufferedReader(new InputStreamReader(this.in = in));
    }

    public String nextLine() {
        try {
            return br.readLine();
        }
        catch (Exception e) {
            return null;
        }
    }

    }

class ParseUtil {

    public static int[] parseIntArray(String lst) {
        String[] s = lst.split("[ ]+");
        int[] arr = new int[s.length];
        for (int i = 0; i < s.length; i++) {
            arr[i] = Integer.parseInt(s[i]);
        }
        return arr;
    }

    }

class ArrayUtil {

    /**
     * Returns a compressed integer array that holds elements from 0 to n, where n is the number of distinct elements in the original array.
     * @param arr The array to compress
     * @return The compressed array
     */
    public static int[] compress(int arr[]) {
        TreeSet<Integer> set = new TreeSet<Integer>();
        HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
        for (int i: arr) {
            set.add(i);
        }
        int cnt = 0;
        for (Integer i: set) {
            map.put(i, cnt);
            cnt++;
        }
        int[] res = new int[arr.length];
        for (int i = 0; i < arr.length; i++) {
            res[i] = map.get(arr[i]);
        }
        return res;
    }

    /**
     * @param arr The array whose maximum integer is to be determined.
     * @return The maximum integer of the array.
     */
    public static int max(int[] arr) {
        if (arr.length == 0) {
            throw new RuntimeException("Passed in array has length of 0");
        }
        int max = arr[0];
        for (int a: arr) {
            if (a > max) {
                max = a;
            }
        }
        return max;
    }

    }

class SuffixArray {
    final long CMP1_SHIFT = 42;
    final long CMP2_SHIFT = 21;
    final long IDX_MASK = (1L << CMP2_SHIFT) - 1;
    int len;
    int lvls = 2;
    int rank[][];
    int idx[];
    int inv[];
    long[] suffixes;

    public SuffixArray(String str) {
        int[] arr = new int[str.length()];
        for (int i = 0; i < str.length(); i++) {
            arr[i] = str.charAt(i);
        }
    }
    public SuffixArray(int[] arr) {
        len = arr.length;
        while ((1 << (lvls - 2)) < len) {
            lvls++;
        }
        rank = new int[lvls][len];
        idx = new int[len];
        inv = new int[len];
        suffixes = new long[len];
        for (int i = 0; i < len; i++) {
            rank[0][i] = arr[i];
        }

        for (int step = 1, count = 1; count >> 1 < len; step++, count <<= 1) {
            for (int i = 0; i < len; i++) {
                long cmp1 = rank[step - 1][i];
                long cmp2 = i + count < len ? rank[step - 1][i + count] + 1
                        : 0;
                suffixes[i] = (cmp1 << CMP1_SHIFT) | (cmp2 << CMP2_SHIFT) | i;
            }
            Arrays.sort(suffixes);
            for (int i = 1; i < len; i++) {
                rank[step][(int) (suffixes[i] & IDX_MASK)] =
                        Long.compare(suffixes[i] >>> CMP2_SHIFT, suffixes[i - 1] >>> CMP2_SHIFT) == 0 ? rank[step][(int) (suffixes[i - 1] & IDX_MASK)]
                                : i;
            }
        }
        for (int i = 0; i < len; i++) {
            idx[i] = (int) (suffixes[i] & IDX_MASK);
        }
        for (int i = 0; i < len; i++) {
            inv[idx[i]] = i;
        }
    }

    public int lcp(int x, int y) {
        int res = 0;
        if (x == y) {
            return len - x;
        }
        for (int k = lvls - 1; k >= 0 && x < len && y < len; k--) {
            if (rank[k][x] == rank[k][y]) {
                x += 1 << k;
                y += 1 << k;
                res += 1 << k;
            }
        }
        return res;
    }
}

