Problem: 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 

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int n = 100001;
int a[n];
void qs(int q, int w, int *s) {
  int e = q, r = w, t = a[s[q + (rand() % (w - q + 1))]], y;
  do {
    while (a[s[e]] < t) e++;
    while (a[s[r]] > t) r--;
    if (e <= r) {
      y = s[e];
      s[e] = s[r];
      s[r] = y;
      e++;
      r--;
    }
  } while (e <= r);
  if (q < r) qs(q, r, s);
  if (e < w) qs(e, w, s);
}
int *sfms(int *a, int q) {
  int w, e, r, t = 0, t1, c, i, *s = new int[q], *d = new int[q],
               *f = new int[q], *g = new int[q], *h = new int[q];
  for (w = 0; w < q; w++) s[w] = w;
  qs(0, q - 1, s);
  d[s[0]] = 0;
  for (w = 1; w < q; w++) {
    if (a[s[w]] != a[s[w - 1]]) t++;
    d[s[w]] = t;
  }
  t++;
  for (i = 1; (i < q) && (t < q); i <<= 1) {
    for (w = 0; w < t; w++) g[w] = -1;
    for (w = q - 1; w >= 0; w--) {
      h[d[s[w]]] = w;
      e = s[w] + i;
      if (e >= q) e -= q;
      e = d[e];
      f[s[w]] = g[e];
      g[e] = s[w];
    }
    t1 = -1;
    for (w = 0; w < t; w++) {
      r = -1;
      for (e = g[w]; e >= 0; e = f[e]) {
        c = d[e];
        s[h[c]] = e;
        h[c]++;
        if (r != c) {
          r = c;
          t1++;
        }
        d[e] = t1;
      }
    }
    t = t1 + 1;
    e = r = -1;
    for (w = 0; w < q; w++) {
      if (e != d[s[w]]) {
        e = d[s[w]];
        r++;
      }
      d[s[w]] = r;
    }
  }
  delete (d);
  delete (f);
  delete (g);
  delete (h);
  return s;
}
int d[n], f[n], h[n * 5], h1[n * 5];
void qs1(int q, int w) {
  int e = q, r = w, y = q + (rand() % (w - q + 1)), t = h[y], t1 = h1[y];
  do {
    while ((h[e] < t) || ((h[e] == t) && (h1[e] < t1))) e++;
    while ((h[r] > t) || ((h[r] == t) && (h1[r] > t1))) r--;
    if (e <= r) {
      y = h[e];
      h[e] = h[r];
      h[r] = y;
      y = h1[e];
      h1[e] = h1[r];
      h1[r] = y;
      e++;
      r--;
    }
  } while (e <= r);
  if (q < r) qs1(q, r);
  if (e < w) qs1(e, w);
}
int main() {
  int q, w, e, r, t, *s, y;
  scanf("%d", &q);
  for (w = 0; w < q; w++) scanf("%d", &a[w]);
  a[q] = -1;
  q++;
  s = sfms(a, q);
  t = 0;
  for (w = 0; w < q; w++) f[s[w]] = w;
  for (w = 0; w < q; w++) {
    if (f[w] == q - 1) {
      t = d[f[w]] = 0;
      continue;
    }
    t = max(t - 1, 0);
    e = s[f[w] + 1];
    for (; (w + t < q) && (e + t < q); t++)
      if (a[w + t] != a[e + t]) break;
    d[f[w]] = t;
  }
  t = 0;
  for (w = 0; w < q; w++) {
    r = q;
    for (e = w;; e++) {
      r = min(r, d[e]);
      if (!r) break;
      if (r >= abs(s[w] - s[e + 1])) {
        h[t] = abs(s[w] - s[e + 1]);
        h1[t] = min(s[w], s[e + 1]);
        t++;
      }
    }
  }
  if (t) qs1(0, t - 1);
  y = 0;
  for (w = 0; w < t; w++)
    if (y <= h1[w]) y = h1[w] + h[w];
  printf("%d\n", q - y - 1);
  for (w = y; w < q - 1; w++) printf("%d ", a[w]);
  return 0;
}