#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;
}
