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 long long maxn = 1e5 + 500;
long long mod2 = 1e9 + 7;
long long base2 = 373;
long long mod1 = 1e9 + 9;
long long base1 = 737;
const long long inf = 1e9 + 500;
long long minn[maxn];
long long a[maxn];
long long b[maxn];
long long c[maxn];
long long hashh[maxn][2];
long long tavv[maxn][2];
vector<long long> vec[maxn];
pair<long long, long long> find_hash(long long l, long long r) {
  if (l == 0) {
    return make_pair(hashh[r][0], hashh[r][1]);
  }
  return make_pair(
      (hashh[r][0] - (hashh[l - 1][0] * tavv[r - l + 1][0]) % mod1 + mod1) %
          mod1,
      (hashh[r][1] - (hashh[l - 1][1] * tavv[r - l + 1][1]) % mod2 + mod2) %
          mod2);
}
long long poww(long long a, long long b, long long mod) {
  long long ans = 1;
  while (b > 0) {
    if (b & 1) {
      ans = (ans * a) % mod;
    }
    a = (a * a) % mod;
    b = (b >> 1);
  }
  return ans;
}
int main() {
  tavv[0][0] = 1;
  for (long long i = 1; i < maxn; i++) {
    tavv[i][0] = (tavv[i - 1][0] * base1) % mod1;
  }
  tavv[0][1] = 1;
  for (long long i = 1; i < maxn; i++) {
    tavv[i][1] = (tavv[i - 1][1] * base2) % mod2;
  }
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
    c[i] = b[i];
  }
  sort(b, b + n);
  for (long long i = 0; i < n; i++) {
    a[i] = lower_bound(b, b + n, a[i]) - b;
  }
  hashh[0][0] = a[0];
  hashh[0][1] = a[0];
  for (long long i = 1; i < n; i++) {
    hashh[i][0] = ((hashh[i - 1][0] * base1) + a[i]) % mod1;
    hashh[i][1] = ((hashh[i - 1][1] * base2) + a[i]) % mod2;
  }
  for (long long i = 0; i < n; i++) {
    vec[a[i]].push_back(i);
  }
  fill(minn, minn + n, inf);
  set<pair<long long, long long> > st;
  for (long long i = 0; i < maxn; i++) {
    for (long long j = 0; j < vec[i].size(); j++) {
      for (long long z = j + 1; z < vec[i].size(); z++) {
        long long v = vec[i][j];
        long long u = vec[i][z];
        if (find_hash(v, u - 1) == find_hash(u, 2 * u - v - 1)) {
          minn[v] = min(minn[v], u - v);
        }
      }
    }
  }
  for (long long i = 0; i < n; i++) {
    if (minn[i] <= n) {
      st.insert(make_pair(minn[i], i));
    }
  }
  long long l = 0;
  while (st.size()) {
    pair<long long, long long> v = (*st.begin());
    st.erase(v);
    long long u = v.second;
    for (long long i = l; i < u + minn[u]; i++) {
      if (minn[i] <= n) {
        st.erase(make_pair(minn[i], i));
      }
    }
    l = u + minn[u];
  }
  cout << n - l << endl;
  for (long long i = l; i < n; i++) {
    cout << c[i] << ' ';
  }
}