#include <bits/stdc++.h>
using namespace std;
const int M = 1e5 + 3, B = 11117;
int nx[M], a[M], tmp[M], mp[M];
unsigned long long num[M], per[M];
int main() {
  int n;
  per[0] = 1;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", a + i), tmp[i] = a[i];
  sort(tmp + 1, tmp + 1 + n);
  int sz = unique(tmp + 1, tmp + 1 + n) - tmp - 1;
  for (int i = 1; i <= n; i++) {
    int p = lower_bound(tmp + 1, tmp + 1 + sz, a[i]) - tmp;
    per[i] = per[i - 1] * B;
    num[i] = num[i - 1] * B + p;
    if (mp[p]) nx[mp[p]] = i;
    mp[p] = i;
  }
  int ct = 0, mr = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = nx[i]; j; j = nx[j]) {
      if (j - i > i) break;
      if (i + i - j >= mr &&
          num[i] - num[i + i - j] * per[j - i] == num[j] - num[i] * per[j - i])
        mr = i;
    }
  }
  printf("%d\n", n - mr);
  for (int i = mr + 1; i <= n; i++) printf("%d ", a[i]);
  puts("");
  return 0;
}
