#include <bits/stdc++.h>
using namespace std;
const int inf = 1999999999;
const double pi = acos(-1.0);
const double eps = 1e-9;
char gc() {
  char c;
  while (isspace(c = getchar()))
    ;
  return c;
}
int gs(char* s) {
  gets(s);
  int l = strlen(s);
  while (l && isspace(s[l - 1])) s[--l] = 0;
  return l;
}
const unsigned hbase = 1000931;
int a[100000];
unsigned p[100010], h[100010];
pair<int, int> t[100000];
int main() {
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    t[i].first = a[i];
    t[i].second = i;
  }
  p[0] = 1;
  for (int i = 1; i <= n; i++) p[i] = p[i - 1] * hbase;
  for (int i = 0; i < n; i++) h[i + 1] = h[i] * hbase + a[i];
  sort(t, t + n);
  vector<pair<int, int> > v;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n && t[i].first == t[j].first; j++) {
      int a = t[i].second, b = t[j].second;
      if (h[b] - h[a] * p[b - a] == h[b * 2 - a] - h[b] * p[b - a])
        v.push_back(make_pair(b - a, a));
    }
  sort((v).begin(), (v).end());
  int pos = 0;
  for (int i = 0; i < ((int)(v).size()); i++)
    if (v[i].second >= pos) pos = v[i].second + v[i].first;
  cout << n - pos << ('\n');
  for (int i = pos; i < n; i++) cout << (i != pos ? " " : "") << a[i];
  return 0;
}
