#include <bits/stdc++.h>
using namespace std;
long long p = 31;
vector<long long> power(100001);
bool customComp(pair<long long, long long> a, pair<long long, long long> b) {
  if (a.second - a.first < b.second - b.first)
    return true;
  else if (a.second - a.first == b.second - b.first) {
    if (a.first < b.first)
      return true;
    else
      return false;
  }
  return false;
}
void solve() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<long long> hash(n + 1);
  hash[n] = 0;
  for (long long i = n - 1; i >= 0; i--) {
    hash[i] = hash[i + 1] * p + a[i];
    hash[i] = hash[i] % 1000000007;
  }
  map<long long, vector<long long>> mp;
  for (long long i = 0; i < n; i++) {
    mp[a[i]].push_back(i);
  }
  long long ans = 0;
  vector<pair<long long, long long>> repeats;
  for (auto i : mp) {
    for (long long j = 0; j < i.second.size() - 1; j++) {
      for (long long k = j + 1; k < i.second.size(); k++) {
        repeats.push_back({i.second[j], i.second[k]});
      }
    }
  }
  sort(repeats.begin(), repeats.end(), customComp);
  for (auto i : repeats) {
    if (i.first < ans) continue;
    long long len = i.second - i.first;
    if (i.second + len > n) continue;
    long long hash1, hash2;
    hash1 = hash[i.second] * power[len];
    hash1 = hash1 % 1000000007;
    hash1 = hash[i.first] - hash1;
    hash1 += 1000000007;
    hash1 %= 1000000007;
    hash2 = hash[i.second + len] * power[len];
    hash2 = hash2 % 1000000007;
    hash2 = hash[i.second] - hash2;
    hash2 += 1000000007;
    hash2 %= 1000000007;
    if (hash1 == hash2) ans = max(ans, i.second);
  }
  cout << n - ans << endl;
  for (long long i = ans; i < n; i++) {
    cout << a[i] << " ";
  }
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  power[0] = 1;
  for (long long i = 1; i < 100001; i++) {
    power[i] = power[i - 1] * p;
    power[i] = power[i] % 1000000007;
  }
  long long t = 1;
  while (t--) {
    solve();
  }
}
