#include <bits/stdc++.h>
using namespace std;
int n;
int a[200000];
long long powX[200000], h[200000];
map<int, vector<int> > m;
vector<pair<int, int> > v;
long long get_hash(int lo, int hi) {
  long long um = (h[hi + 1] - h[lo] * powX[hi + 1 - lo]) % 1000000007LL;
  return (um + 1000000007LL) % 1000000007LL;
}
int main() {
  scanf("%d", &n);
  powX[0] = 1;
  h[0] = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    h[i + 1] = (a[i] + 343121343LL * h[i]) % 1000000007LL;
    powX[i + 1] = (343121343LL * powX[i]) % 1000000007LL;
    m[a[i]].push_back(i);
  }
  for (map<int, vector<int> >::iterator it = m.begin(); it != m.end(); it++) {
    vector<int> w = it->second;
    for (int i = 0; i < (int)w.size(); i++) {
      for (int j = i + 1; j < (int)w.size(); j++) {
        v.push_back(make_pair(w[j] - w[i], w[i]));
      }
    }
  }
  sort(v.begin(), v.end());
  int at = 0;
  for (int i = 0; i < (int)v.size(); i++) {
    if (v[i].second < at) continue;
    int x = v[i].second;
    int l = v[i].first;
    if (x + 2 * l <= n &&
        get_hash(x, x + l - 1) == get_hash(x + l, x + 2 * l - 1)) {
      at = x + l;
    }
  }
  printf("%d\n", n - at);
  for (int i = at; i < n; i++) {
    printf("%d ", a[i]);
  }
  printf("\n");
}
