#include <bits/stdc++.h>
using namespace std;
int n, L, x, a[100005], sum[100005], pre[100005], cnt;
int mul[100005], p = 37;
map<int, int> pos;
struct node {
  int id, len;
  node() {}
  node(int a, int b) {
    id = a;
    len = b;
  }
  bool operator<(const node &t) const {
    if (len != t.len) return len < t.len;
    return id < t.id;
  }
} Q[100005];
int Hash(int x, int y) { return sum[y] - sum[x] * mul[y - x]; }
bool check(int x, int y) { return Hash(x, y - 1) == Hash(y, y + y - x - 1); }
int main() {
  scanf("%d", &n), L = mul[0] = 1;
  for (int i = 1; i <= n; i++) mul[i] = mul[i - 1] * p;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    sum[i] = sum[i - 1] * p + a[i];
    pre[i] = pos[a[i]];
    pos[a[i]] = i;
  }
  for (int i = 1; i <= n; i++) {
    x = pre[i];
    while (x && !check(x, i)) x = pre[x];
    if (x) Q[++cnt] = node(i, i - x);
  }
  sort(Q + 1, Q + 1 + cnt);
  for (int i = 1; i <= cnt; i++)
    if (Q[i].id - Q[i].len >= L) L = Q[i].id;
  printf("%d\n", n - L + 1);
  for (int i = L; i <= n; i++) printf("%d ", a[i]);
}
