#include <bits/stdc++.h>
using namespace std;
const int white = 0, gray = 1, black = 2;
const int inf = 0x0fffffff;
const int size = 100000;
int ar[size];
int n;
struct Num {
  int num;
  int diff;
  int pos;
};
bool operator<(const Num &a, const Num &b) {
  if (a.diff == b.diff) return a.pos < b.pos;
  return a.diff < b.diff;
}
int l = 0;
map<int, vector<int> > m;
int Solution(int nTest) {
  scanf("%d", &n);
  for (int i = (0); i < (n); i++) {
    scanf("%d", &ar[i]);
    m[ar[i]].push_back(i);
  }
  vector<Num> v;
  map<int, vector<int> >::iterator it = m.begin();
  while (it != m.end()) {
    for (int i = (1); i < (it->second.size()); i++) {
      Num temp;
      temp.num = it->first;
      temp.pos = it->second[i - 1];
      temp.diff = it->second[i] - it->second[i - 1];
      v.push_back(temp);
    }
    it++;
  }
  sort(v.begin(), v.end());
  for (int i = (0); i < (v.size()); i++) {
    if (v[i].pos < l) continue;
    int flag = 0;
    for (int j = (v[i].pos); j < (v[i].pos + v[i].diff); j++) {
      if (ar[j] != ar[j + v[i].diff]) {
        flag = 1;
        break;
      }
    }
    if (flag == 0) {
      l = v[i].pos + v[i].diff;
    }
  }
  int res = n - l;
  printf("%d\n", res);
  for (int i = (l); i < (n); i++) printf("%d ", ar[i]);
  printf("\n");
  return 0;
}
int main() {
  int i = 0, n = 99999;
  while (i < n && Solution(i)) {
    i++;
  }
  return 0;
}
