#include <bits/stdc++.h>
using namespace std;
const long long base = 1e9 + 7;
const long long mod = 100000007;
vector<pair<long long, pair<long long, int> > > s;
pair<long long, int> a[100005];
long long h[100005], pow1[100005];
int d[100005], a1[100005];
int n, kq;
void nhap() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i].first;
    a[i].second = i;
    a1[i] = a[i].first;
  }
}
void prep() {
  pow1[0] = 1;
  for (int i = 1; i <= n; ++i) {
    h[i] = (h[i - 1] * base + a[i].first + 1) % mod;
    pow1[i] = (pow1[i - 1] * base) % mod;
  }
}
long long get(int l1, int r1) {
  return (h[r1] - h[l1 - 1] * pow1[r1 - l1 + 1] + mod * mod) % mod;
}
void xl() {
  sort(a + 1, a + 1 + n);
  for (int i = 1; i <= n; ++i) {
    int i1 = i;
    while (a[i1 + 1].first == a[i].first && i1 <= n) ++i1;
    for (int j = i; j <= i1 - 1; ++j) {
      int l1, r1, l2, r2;
      l1 = a[j].second;
      r1 = a[j + 1].second - 1;
      l2 = a[j + 1].second;
      r2 = min(a[j + 1].second + (r1 - l1), n);
      long long s1 = get(l1, r1);
      long long s2 = get(l2, r2);
      if (s1 == s2) {
        pair<long long, pair<long long, int> > t;
        t.second.first = a[j + 1].second;
        t.first = r1 - l1 + 1;
        t.second.second = a[j].second;
        s.push_back(t);
      }
      i = i1;
    }
  }
  kq = 1;
  sort(s.begin(), s.end());
  for (int i = 0; i < s.size(); ++i)
    if (s[i].second.first > kq && s[i].second.second >= kq)
      kq = s[i].second.first;
  cout << n - kq + 1 << '\n';
  for (int i = kq; i <= n; ++i) cout << a1[i] << ' ';
}
int main() {
  nhap();
  prep();
  xl();
  return 0;
}
