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;
ostream& operator<<(ostream& os, pair<long long int, long long int> h) {
  return os << "( " << h.first << ", " << h.second << " )" << endl;
}
pair<long long int, long long int> operator+(
    pair<long long int, long long int> a, long long int x) {
  return {a.first + x, a.second + x};
}
pair<long long int, long long int> operator-(
    pair<long long int, long long int> a, long long int x) {
  return {a.first - x, a.second - x};
}
pair<long long int, long long int> operator*(
    pair<long long int, long long int> a, long long int x) {
  return {a.first * x, a.second * x};
}
pair<long long int, long long int> operator+(
    pair<long long int, long long int> x,
    pair<long long int, long long int> y) {
  return {x.first + y.first, x.second + y.second};
}
pair<long long int, long long int> operator-(
    pair<long long int, long long int> x,
    pair<long long int, long long int> y) {
  return {x.first - y.first, x.second - y.second};
}
pair<long long int, long long int> operator*(
    pair<long long int, long long int> x,
    pair<long long int, long long int> y) {
  return {x.first * y.first, x.second * y.second};
}
pair<long long int, long long int> operator%(
    pair<long long int, long long int> x,
    pair<long long int, long long int> y) {
  return {x.first % y.first, x.second % y.second};
}
const pair<long long int, long long int> p = {15485867, 32452843};
const pair<long long int, long long int> mod = {1000000021, 1e9 + 9};
pair<long long int, long long int> p_pow[1000006], h[1000006];
int ara[1000006], tmp[1000006];
map<int, int> mp;
int tot, n;
vector<int> edg[1000006];
vector<pair<int, int> > rec;
pair<long long int, long long int> getHash(int id, int len) {
  pair<long long int, long long int> tmp =
      (h[id + len - 1] + mod - h[id - 1]) % mod;
  tmp = (tmp * p_pow[1000006 - 1 - id]) % mod;
  return tmp;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> ara[i], tmp[i] = ara[i];
  for (int i = 0; i < n; i++) {
    if (mp.count(ara[i]) == 0) {
      mp[ara[i]] = ++tot;
    }
    ara[i] = mp[ara[i]];
  }
  for (int i = 0; i < n; i++) {
    edg[ara[i]].push_back(i + 1);
  }
  p_pow[0] = {1, 1};
  for (int i = 1; i < 1000006; i++) {
    p_pow[i] = (p_pow[i - 1] * p) % mod;
  }
  for (int i = 0; i < n; i++) {
    h[i + 1] = (h[i] + p_pow[i] * ara[i]) % mod;
  }
  for (int i = 1; i <= tot; i++) {
    for (int j = 0; j < edg[i].size(); j++) {
      for (int k = j + 1; k < edg[i].size(); k++) {
        int id1 = edg[i][j];
        int id2 = edg[i][k];
        int len = id2 - id1;
        if (n - id2 + 1 < len) continue;
        if (getHash(id1, len) == getHash(id2, len)) {
          rec.push_back({len, id1});
        }
      }
    }
  }
  sort(rec.begin(), rec.end());
  int frm = 1;
  for (int i = 0; i < rec.size(); i++) {
    int len = rec[i].first;
    int pos = rec[i].second;
    if (pos < frm) continue;
    frm = pos + len;
  }
  frm--;
  cout << n - frm << endl;
  for (int i = frm; i < n; i++) cout << tmp[i] << " ";
  cout << endl;
  return 0;
}