#include <bits/stdc++.h>
using namespace std;
int n, a[100001];
map<int, list<int>> q;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    q[a[i]].push_back(i);
  }
  a[n] = -1;
  int t = 0;
  for (int i = 0; i < n; i++) {
    list<int>& r = q[a[i]];
    r.pop_front();
    for (auto c : r) {
      int x = i, y = c;
      do x++, y++;
      while (x < c && a[x] == a[y]);
      if (x == c) i = (t = c) - 1;
    }
  }
  printf("%d\n", n - t);
  while (t < n) printf("%d ", a[t++]);
}
