#include <bits/stdc++.h>
using namespace std;
const int maxN = 100000;
const int maxK = 10;
vector<int> V(maxN), link(maxN, -1);
vector<int> pos(maxN, 0);
int longest[maxN][maxK];
vector<pair<int, int> > longitud(maxN);
map<int, int> T;
int sortFunction(pair<int, int> a, pair<int, int> b) {
  if (a.second < b.second) return 1;
  if (a.second > b.second) return 0;
  return a.first < b.first;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int n, i, j, l, k, l2;
  map<int, int>::iterator it;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> V[i];
    it = T.find(V[i]);
    if (it == T.end()) {
      T.insert(pair<int, int>(V[i], i));
      pos[i] = 0;
    } else {
      link[it->second] = i;
      pos[i] = pos[it->second] + 1;
      it->second = i;
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < 10; j++) longest[i][j] = -1;
  }
  for (i = 0; i < n; i++) {
    j = link[i];
    for (k = 0; j != -1; k++) {
      if (longest[i][k] == -1) {
        for (l = 0; j + l < n; l++) {
          if (V[i + l] != V[j + l]) break;
        }
        for (l2 = 0; l2 < l; l2++)
          longest[i + l2][pos[j + l2] - pos[i + l2] - 1] = l - l2;
      }
      j = link[j];
    }
  }
  for (i = 0; i < n; i++) {
    longitud[i].first = i;
    longitud[i].second = 1e7;
  }
  for (i = 0; i < n; i++) {
    j = link[i];
    for (k = 0; j != -1; k++) {
      if (longest[i][k] != -1) {
        if (i + longest[i][k] >= j) {
          longitud[i].second = j - i;
          break;
        }
      }
      j = link[j];
    }
  }
  sort(longitud.begin(), longitud.begin() + n, sortFunction);
  for (i = 0, j = 0; i < n; i++) {
    if (longitud[i].first >= j && longitud[i].second != 1e7)
      j = longitud[i].first + longitud[i].second;
  }
  cout << n - j << '\n';
  for (i = j; i < n; i++) {
    if (i > j) cout << " ";
    cout << V[i];
  }
  cout << '\n';
}
