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 = 1e5 + 5;
const int Base[3] = {101111, 101113, 101117};
const int Mod[3] = {(int)1e9 + 7, (int)1e9 + 9, 19260817};
long long pB[3][N];
void init() {
  for (int k = (0), kEND = (2); k <= kEND; ++k) {
    pB[k][0] = 1;
    for (int i = (1), iEND = (N - 1); i <= iEND; ++i)
      pB[k][i] = pB[k][i - 1] * Base[k] % Mod[k];
  }
}
int a[N], n;
int disc[N], tot;
long long s[3][N];
struct node {
  int x, len;
  bool operator<(const node &_) const {
    if (len != _.len) return len < _.len;
    return x < _.x;
  }
} Q[N * 10];
int cnt;
int las[N];
long long S(int k, int x, int y) {
  return ((s[k][y] - s[k][x - 1] * pB[k][y - x + 1]) % Mod[k] + Mod[k]) %
         Mod[k];
}
bool judge(int L1, int R1, int L2, int R2) {
  bool flg = 1;
  for (int k = (0), kEND = (2); k <= kEND; ++k)
    flg &= (S(k, L1, R1) == S(k, L2, R2));
  return flg;
}
int main() {
  init();
  scanf("%d", &n);
  for (int i = (1), iEND = (n); i <= iEND; ++i) scanf("%d", &a[i]);
  for (int i = (1), iEND = (n); i <= iEND; ++i) disc[++tot] = a[i];
  sort(disc + 1, disc + 1 + tot);
  tot = unique(disc + 1, disc + 1 + tot) - disc - 1;
  for (int i = (1), iEND = (n); i <= iEND; ++i)
    a[i] = lower_bound(disc + 1, disc + 1 + tot, a[i]) - disc;
  for (int k = (0), kEND = (2); k <= kEND; ++k) {
    s[k][0] = 1;
    for (int i = (1), iEND = (n); i <= iEND; ++i)
      s[k][i] = (s[k][i - 1] * Base[k] + a[i]) % Mod[k];
  }
  memset(las, -1, sizeof(las));
  for (int i = (1), iEND = (n); i <= iEND; ++i) {
    if (las[a[i]] != -1) {
      int x = las[a[i]], len = i - x;
      if (i + len - 1 <= n) Q[++cnt] = (node){x, len};
    }
    las[a[i]] = i;
  }
  sort(Q + 1, Q + 1 + cnt);
  int l = 1;
  for (int i = (1), iEND = (cnt); i <= iEND; ++i)
    if (l <= Q[i].x && judge(Q[i].x, Q[i].x + Q[i].len - 1, Q[i].x + Q[i].len,
                             Q[i].x + 2 * Q[i].len - 1))
      l = Q[i].x + Q[i].len;
  printf("%d\n", n - l + 1);
  for (int i = (l), iEND = (n); i <= iEND; ++i) printf("%d ", disc[a[i]]);
  return 0;
}