#include <bits/stdc++.h>
using namespace std;
const pair<long long, long long> M = make_pair(1e9 + 7, 1e9 + 9);
const long long base = 875329;
const int N = 1e5 + 7;
ostream &operator<<(ostream &os, pair<long long, long long> hash) {
  return os << "(" << hash.first << ", " << hash.second << ")";
}
pair<long long, long long> operator+(pair<long long, long long> a,
                                     long long x) {
  return make_pair(a.first + x, a.second + x);
}
pair<long long, long long> operator-(pair<long long, long long> a,
                                     long long x) {
  return make_pair(a.first - x, a.second - x);
}
pair<long long, long long> operator*(pair<long long, long long> a,
                                     long long x) {
  return make_pair(a.first * x, a.second * x);
}
pair<long long, long long> operator+(pair<long long, long long> a,
                                     pair<long long, long long> x) {
  return make_pair(a.first + x.first, a.second + x.second);
}
pair<long long, long long> operator-(pair<long long, long long> a,
                                     pair<long long, long long> x) {
  return make_pair(a.first - x.first, a.second - x.second);
}
pair<long long, long long> operator*(pair<long long, long long> a,
                                     pair<long long, long long> x) {
  return make_pair(a.first * x.first, a.second * x.second);
}
pair<long long, long long> operator%(pair<long long, long long> a,
                                     pair<long long, long long> m) {
  return make_pair(a.first % m.first, a.second % m.second);
}
pair<long long, long long> pb[N];
void pre() {
  pb[0] = make_pair(1, 1);
  for (int i = 1; i < N; i++) pb[i] = (pb[i - 1] * base) % M;
}
vector<pair<long long, long long> > hashList(vector<int> s) {
  int n = s.size();
  vector<pair<long long, long long> > ans(n + 1);
  ans[0] = make_pair(0, 0);
  for (int i = 1; i <= n; i++) ans[i] = (ans[i - 1] * base + s[i - 1]) % M;
  return ans;
}
pair<long long, long long> Hash(vector<pair<long long, long long> > &hashlist,
                                int l, int r) {
  int len = (r - l + 1);
  return ((hashlist[r] - hashlist[l - 1] * pb[len]) % M + M) % M;
}
void compress(vector<int> &a) {
  map<int, int> id;
  for (int i = 0; i < a.size(); i++) {
    if (id.count(a[i]) == 0) id[a[i]] = id.size();
    a[i] = id[a[i]];
  }
}
bool check(vector<pair<long long, long long> > &hashList, int i, int j) {
  int n = hashList.size() - 1;
  int len = j - i;
  if (j + len - 1 > n) return false;
  return Hash(hashList, i, i + len - 1) == Hash(hashList, j, j + len - 1);
}
int main() {
  pre();
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<int> b = a;
  compress(a);
  vector<pair<long long, long long> > ha = hashList(a);
  a.insert(a.begin(), -1);
  map<int, vector<int> > pos;
  vector<pair<int, int> > repeats;
  for (int i = n; i > 0; i--) {
    for (auto v : pos[a[i]])
      if (check(ha, i, v)) repeats.push_back(make_pair(v - i, i));
    pos[a[i]].push_back(i);
  }
  sort(repeats.begin(), repeats.end());
  int start = 1;
  for (auto v : repeats) {
    if (v.second < start) continue;
    start = v.second + v.first;
  }
  cout << n - start + 1 << endl;
  ;
  for (int i = start; i <= n; i++) cout << b[i - 1] << " ";
}
