#include <bits/stdc++.h>
using namespace std;
const unsigned long long P = 1000000007;
const unsigned long long M = 1073676287;
vector<unsigned long long> p(100001, 1);
vector<unsigned long long> hsh(100001, 0);
unsigned long long h(int l, int r) {
  return (hsh[r] - (hsh[l] * p[r - l]) % M + M) % M;
}
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> s(n);
  map<int, vector<int> > same;
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
    same[s[i]].push_back(i);
  }
  for (int i = 1; i <= n; ++i) {
    p[i] = p[i - 1] * P % M;
    hsh[i] = (hsh[i - 1] * P + s[i - 1] + 1) % M;
  }
  vector<pair<int, int> > repeats;
  for (int i = 0; i < n - 1; ++i) {
    for (int j : same[s[i]]) {
      if (j <= i || j + j - i > n) continue;
      if (h(i, j) != h(j, j + j - i)) continue;
      repeats.push_back({j - i, j});
    }
  }
  sort(repeats.begin(), repeats.end());
  int left = 0;
  for (auto rep : repeats) {
    if (rep.second - rep.first >= left) left = rep.second;
  }
  cout << n - left << endl;
  for (; left < n; ++left) cout << s[left] << " ";
}
