#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 28;
const double INF = 1e12, EPS = 1e-9;
int n, m;
int num[100000], a[100000];
int pos[100000][10], np[100000];
int ans[100000], len;
int find(int v, int p) {
  int k = 0;
  while (pos[v][k] <= p) k++;
  for (; k < np[v]; k++) {
    int l = 0;
    while (num[p + l] == num[pos[v][k] + l] && l + p < pos[v][k]) l++;
    if (l + p == pos[v][k]) return l;
  }
  return -1;
}
void run() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> num[i], a[i] = num[i];
  sort(a, a + n);
  m = unique(a, a + n) - a;
  fill_n(np, m, 0);
  for (int i = 0; i < n; i++) {
    num[i] = lower_bound(a, a + m, num[i]) - a;
    pos[num[i]][np[num[i]]++] = i;
  }
  len = 0;
  for (int i = 0; i < n; i++) {
    int l = find(num[i], i);
    if (l < 0)
      ans[len++] = a[num[i]];
    else
      i += l - 1, len = 0;
  }
  cout << len << endl;
  for (int i = 0; i < len; i++) cout << ans[i] << (i == len - 1 ? "\n" : " ");
}
int main() { run(); }
