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 = 100010;
const int MX = 123456;
const int base = 1023456789;
const unsigned long long BS1 = 10000019ULL;
const int INF = (1 << 29);
template <class T>
inline void fastScan(T &x) {
  register char c = getchar();
  int neg = 0;
  x = 0;
  for (; (c < 48 || c > 57) && (c != '-'); c = getchar())
    ;
  if (c == '-') {
    neg = 1;
    c = getchar();
  }
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  if (neg) x = -x;
}
int mod[] = {999999937, 999999929};
int BS[] = {31, 37};
int n;
int st;
int f1[N];
int f2[N];
int mn[N];
int len[N];
int inp[N];
int point[N];
int hashing1[N];
int hashing2[N];
map<int, vector<int> > mymap;
int P(int a, int b, int c) {
  int ret = 1;
  while (b > 0) {
    if (b & 1) {
      ret = 1ll * ret * a % c;
    }
    b /= 2;
    a = 1ll * a * a % c;
  }
  return ret;
}
int hashVal1(int l, int r) {
  int up = hashing1[r] - hashing1[l - 1];
  up %= mod[0];
  up += mod[0];
  up %= mod[0];
  int down = P(f1[l - 1], mod[0] - 2, mod[0]) % mod[0];
  up = 1ll * up * down % mod[0];
  return up;
}
int hashVal2(int l, int r) {
  int up = hashing2[r] - hashing2[l - 1];
  up %= mod[1];
  up += mod[1];
  up %= mod[1];
  int down = P(f2[l - 1], mod[1] - 2, mod[1]) % mod[1];
  up = 1ll * up * down % mod[1];
  return up;
}
int Solve(int idx) {
  int dist = N + N;
  int v = inp[idx];
  for (int i = 0; i < mymap[v].size(); i++) {
    int u = mymap[v][i];
    if (u > idx) {
      if (u - idx <= n - u + 1) {
        if (hashVal1(idx, u - 1) == hashVal1(u, u + u - idx - 1)) {
          if (hashVal2(idx, u - 1) == hashVal2(u, u + u - idx - 1)) {
            dist = min(dist, u - idx);
          }
        }
      }
    }
  }
  return dist;
}
int main() {
  fastScan(n);
  for (int i = 1; i <= n; i++) {
    fastScan(inp[i]);
    inp[i]++;
    mymap[inp[i]].push_back(i);
  }
  f1[0] = 1;
  f2[0] = 1;
  for (int i = 1; i <= n; i++) {
    f1[i] = 1ll * f1[i - 1] * BS[0] % mod[0];
    f2[i] = 1ll * f2[i - 1] * BS[1] % mod[1];
  }
  for (int i = 1; i <= n; i++) {
    hashing1[i] = 1ll * inp[i] * f1[i] % mod[0];
    hashing1[i] += hashing1[i - 1];
    hashing1[i] %= mod[0];
    hashing2[i] = 1ll * inp[i] * f2[i] % mod[1];
    hashing2[i] += hashing2[i - 1];
    hashing2[i] %= mod[1];
  }
  len[n + 1] = N + N;
  point[n + 1] = n + 1;
  mn[n + 1] = N;
  for (int i = n; i >= 1; i--) {
    int x = Solve(i);
    len[i] = x;
    mn[i] = min(mn[i + 1], len[i]);
    if (len[i] > mn[i + 1])
      point[i] = point[i + 1];
    else
      point[i] = i;
  }
  st = 1;
  for (int i = 1; i <= n;) {
    if (point[i] == i) {
      st = i + mn[i];
      i = i + mn[i];
    } else {
      i++;
    }
  }
  printf("%d\n", n - st + 1);
  for (int i = st; i <= n; i++) {
    printf("%d%c", inp[i] - 1, (i == n ? '\n' : ' '));
  }
}