#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10, pw = 3331, md = 999727999;
long long p_h[MAXN], s[MAXN];
vector<int> null;
long long power(int p) {
  if (p == 0) return 1;
  long long ans = power(p / 2);
  ans *= ans;
  ans %= md;
  ans *= (p % 2 ? pw : 1);
  ans %= md;
  return ans;
}
long long h(int l, int r) {
  long long ans = p_h[r];
  ans += md;
  if (l) ans -= p_h[l - 1];
  ans %= md;
  ans *= power(md - l - 1);
  ans %= md;
  return ans;
}
int find(int now, int limit, map<int, vector<int>>& m) {
  for (int k = now; k >= limit; --k) {
    if (m.count(s[k])) {
      m[s[k]].push_back(k);
      for (int i = m[s[k]].size() - 2; i >= 0; --i) {
        int length = m[s[k]][i] - k;
        if (h(k - length + 1, k) == h(k + 1, k + length)) {
          int f = find(k - 1, k - length + 1, m);
          if (f < k - length + 1)
            return k;
          else
            return f;
        }
      }
    } else {
      m[s[k]] = null;
      m[s[k]].push_back(k);
    }
  }
  return limit - 1;
}
int main() {
  int n;
  cin >> n;
  long long k = 1;
  for (int i = 0; i < n; ++i) {
    int a1;
    cin >> a1;
    s[i] = a1;
    if (i) p_h[i] = p_h[i - 1];
    p_h[i] += (a1 * k);
    p_h[i] %= md;
    k *= pw;
    k %= md;
  }
  map<int, vector<int>> m;
  int ans = find(n - 1, 0, m);
  cout << n - ans - 1 << '\n';
  for (int i = ans + 1; i < n; ++i) cout << s[i] << " ";
  return 0;
}
