#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100007;
const int BASE = 10007;
int n;
int a[MAX_N], b[MAX_N];
vector<int> pos[MAX_N];
map<int, int> q;
long long p[MAX_N], s[MAX_N];
long long get_h(int i, int j) {
  if (!i) return s[j];
  return s[j] - s[i - 1] * p[j - i + 1];
}
int solve() {
  int left = -1, i = 0;
  while (i < n) {
    if (i < left) i = left;
    for (int j = 0; j < int(int(pos[a[i]].size())); ++j) {
      int l = pos[a[i]][j], r = 2 * l - i - 1;
      if (l <= i || r >= n) continue;
      if (get_h(i, l - 1) == get_h(l, r)) {
        left = i = l - 1;
        break;
      }
    }
    ++i;
  }
  return ++left;
}
int main() {
  int c = -1;
  cin >> n;
  for (int i = 0; i < int(n); ++i) {
    scanf("%d", &b[i]);
    if (q.find(b[i]) == q.end()) q[b[i]] = ++c;
    a[i] = q[b[i]];
    pos[a[i]].push_back((i));
  }
  p[0] = 1;
  s[0] = a[0];
  for (int i = int(1); i <= int(n); ++i) {
    p[i] = p[i - 1] * BASE;
    s[i] = s[i - 1] * BASE + a[i];
  }
  int res = solve();
  printf("%d\n", n - res);
  for (int i = int(res); i <= int(n - 1); ++i) printf("%d ", b[i]);
  return 0;
}
