#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100000;
const int MAXR = 10;
int main() {
  int n;
  scanf("%d", &n);
  vector<int> seq(n);
  int m = 0;
  map<int, int> mp;
  vector<int> rev;
  vector<vector<int> > occur;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &seq[i]);
    if (mp.find(seq[i]) == mp.end()) {
      mp[seq[i]] = m;
      rev.push_back(seq[i]);
      ++m;
      occur.push_back(vector<int>());
      occur[occur.size() - 1].reserve(10);
    }
    occur[mp[seq[i]]].push_back(i);
  }
  vector<vector<int> > rep(n);
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < occur[i].size(); ++j) {
      for (int k = 1 + j; k < occur[i].size(); ++k) {
        rep[occur[i][k] - occur[i][j]].push_back(occur[i][j]);
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    sort(rep[i].begin(), rep[i].end());
  }
  int begin = 0;
  for (int tam = 1; tam < n; ++tam) {
    for (int ind = 0; ind + tam <= rep[tam].size(); ++ind) {
      if (rep[tam][ind] < begin) continue;
      if (rep[tam][ind] + (tam - 1) == rep[tam][ind + tam - 1]) {
        begin = rep[tam][ind] + tam;
      }
    }
  }
  printf("%d\n", n - begin);
  printf("%d", seq[begin]);
  for (int i = 1 + begin; i < n; ++i) {
    printf(" %d", seq[i]);
  }
  printf("\n");
  return 0;
}
