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;
template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string &s) { return '"' + s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ")";
}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + "," +
         to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug() { cerr << endl; }
template <typename Head, typename... Tail>
void debug(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug(T...);
}
struct fast_power {
  long long integer(long long n, long long e,
                    long long my_mod = 9223372036854775807LL) {
    long long ans = 1;
    while (e) {
      if (e & 1)
        ans = (ans * n) % my_mod, e--;
      else
        n = (n * n) % my_mod, e >>= 1;
    }
    return ans;
  }
  long long matrix(vector<vector<long long>> &n, long long e,
                   long long my_mod = 9223372036854775807LL);
};
struct euclidean {
  int gcdi(int a, int b) { return b ? gcdi(b, a % b) : a; }
  double gcdf(double a, double b, double accuracy) {
    return b <= accuracy ? a : gcdf(b, fmod(a, b), accuracy);
  }
};
const int INF = 0x3f3f3f3f;
const int maxn = 100000 + 5;
unsigned long long h[maxn], xp[maxn];
const long long x = 1000000007;
char s[maxn];
int a[maxn];
map<int, vector<int>> ys;
struct point {
  int l, r;
  bool operator<(const point &rhs) const {
    if (r - l != rhs.r - rhs.l) return r - l < rhs.r - rhs.l;
    return l < rhs.l;
  }
} arr[maxn * 60];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i], ys[a[i]].push_back(i);
  h[n] = 0;
  for (int i = n - 1; i >= 0; i--) h[i] = h[i + 1] * x + a[i];
  xp[0] = 1;
  for (int i = 1; i <= n; i++) xp[i] = xp[i - 1] * x;
  int pos = 0, cnt = 0;
  map<int, int> mp;
  for (int i = 0; i < n; i++)
    if (!mp[a[i]]) {
      mp[a[i]] = 1;
      for (int q = 0; q < ys[a[i]].size(); q++)
        for (int e = q + 1; e < ys[a[i]].size(); e++)
          arr[cnt].l = ys[a[i]][q], arr[cnt++].r = ys[a[i]][e];
    }
  sort(arr, arr + cnt);
  for (int i = 0; i < cnt; i++) {
    if (pos > arr[i].l) continue;
    int len = arr[i].r - arr[i].l;
    if (n - arr[i].r >= len && h[arr[i].l] - h[arr[i].l + len] * xp[len] ==
                                   h[arr[i].r] - h[arr[i].r + len] * xp[len])
      pos = arr[i].r;
  }
  cout << n - pos << endl;
  for (int i = pos; i < n; i++) cout << a[i] << " ";
  cerr << endl;
  return 0;
}