#include <bits/stdc++.h>
const int N = 100010;
const int inf = 0x3f3f3f3f;
using namespace std;
int a[N];
map<int, int> h, nt;
set<pair<int, int> > st;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  for (int i = n - 1; i >= 0; i--) {
    nt[i] = h[a[i]];
    h[a[i]] = i;
  }
  int ret = 0;
  for (int i = 0; i < n; i++) {
    int x = i, y = nt[i];
    if (y == 0) continue;
    st.insert(make_pair(x, y));
    while (a[x + 1] == a[y + 1] && y + 1 < n && x + 1 < nt[i] &&
           st.count(make_pair(x + 1, y + 1)) == 0)
      x++, y++, st.insert(make_pair(x, y));
    if (x + 1 == nt[i]) i = x, ret = x + 1;
  }
  cout << n - ret << endl;
  for (int i = ret; i < n; i++) cout << a[i] << " ";
  cout << endl;
  return 0;
}
