#include <bits/stdc++.h>
using namespace std;
long long hashval[100005], pwr[100005];
int n, ara[100005];
int calc_hash(int l, int r) {
  long long ret = hashval[r + 1];
  ret *= pwr[r - l + 1];
  ret %= 1000075057;
  return (hashval[l] - ret + 1000075057) % 1000075057;
}
void precal_hash(void) {
  int i;
  pwr[0] = 1;
  for (i = 1; i < 100005; i++) {
    pwr[i] = pwr[i - 1] * 52477425;
    pwr[i] %= 1000075057;
  }
  for (i = n - 1; i >= 0; i--) {
    hashval[i] = hashval[i + 1] * 52477425;
    hashval[i] += ara[i];
    hashval[i] %= 1000075057;
  }
}
map<int, vector<int> > allpos;
int main() {
  int i, j;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &ara[i]);
    allpos[ara[i]].push_back(i);
  }
  precal_hash();
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      Q;
  for (map<int, vector<int> >::iterator it = allpos.begin(); it != allpos.end();
       it++) {
    vector<int> ttt = (it->second);
    for (i = 0; i < ttt.size(); i++) {
      for (j = i + 1; j < ttt.size(); j++) {
        int l = ttt[i], r = ttt[j];
        if (r + r - l - 1 < n &&
            calc_hash(l, r - 1) == calc_hash(r, r + r - l - 1))
          Q.push(make_pair(r - l, l));
      }
    }
  }
  int st = 0;
  while (!Q.empty()) {
    pair<int, int> now = Q.top();
    Q.pop();
    if (now.second < st) continue;
    st = now.second + now.first;
  }
  printf("%d\n", n - st);
  for (i = st; i < n; i++) printf("%d ", ara[i]);
  printf("\n");
  return 0;
}
