#include <bits/stdc++.h>
#pragma GCC optimize "trapv"
long long int power(long long int x, long long int b) {
  long long int p = 1;
  while (b > 0) {
    if (b & 1) {
      p = p * x;
      p %= 998244353;
    }
    b >>= 1;
    x *= x;
    x %= 998244353;
  }
  return p % 998244353;
}
std::vector<long long int> fact;
void fact_pre(long long int n = 1100000) {
  fact.resize(n, 1);
  for (long long int i = 2; i < n; i++) fact[i] = (fact[i - 1] * i) % 998244353;
}
long long int ncr(long long int n, long long int r) {
  if (r > n) return 0;
  return (fact[n] * power((fact[n - r] * fact[r]) % 998244353, 998244353 - 2)) %
         998244353;
}
using namespace std;
struct ppp {
  char a;
  long long int b, c, d;
};
long long int N;
struct lex_compare {
  bool operator()(ppp p1, ppp p2) {
    if (p1.a == p2.a) {
      if (p1.b == p2.b)
        return p1.c < p2.c;
      else
        return p1.b < p2.b;
    } else {
      return p1.a < p2.a;
    }
  }
};
long long int base1 = 101, base2 = 31;
long long int hashtotal(vector<long long int> &s, long long int base) {
  long long int ans = 0;
  for (long long int i = 0; i < s.size(); i++) {
    ans += (power(base, i) * s[i]);
    ans %= 998244353;
  }
  return ans;
}
void hashinArray(vector<long long int> &s, long long int base,
                 long long int arr[]) {
  long long int ans = 0;
  for (long long int i = 0; i < s.size(); i++) {
    ans += (power(base, i) * s[i]);
    ans %= 998244353;
    arr[i] = ans;
  }
  return;
}
long long int hashofSubstr(vector<long long int> &s, long long int l,
                           long long int r, long long int arr[],
                           long long int base) {
  long long int temphash = arr[r];
  if (l == 0)
    return temphash;
  else
    temphash -= arr[l - 1];
  temphash += 998244353;
  temphash %= 998244353;
  temphash = temphash * power(power(base, l), 998244353 - 2);
  temphash %= 998244353;
  temphash += 998244353;
  temphash %= 998244353;
  return temphash;
}
void solve() {
  long long int n;
  cin >> n;
  vector<long long int> arr(n);
  for (long long int i = 0; i < n; i++) cin >> arr[i];
  map<long long int, list<long long int>> m;
  priority_queue<pair<long long int, long long int>> repeats;
  for (long long int i = 0; i < n; i++) {
    m[arr[i]].push_back(i);
  }
  long long int hash1[n], hash2[n];
  hashinArray(arr, base1, hash1);
  hashinArray(arr, base2, hash2);
  long long int rightmostalive = 0;
  long long int t = 0;
  for (int i = 0; i < n; i++) {
    list<long long int> &r = m[arr[i]];
    r.pop_front();
    for (auto c : r) {
      int x = i, y = c;
      do x++, y++;
      while (x < c && y < n && arr[x] == arr[y]);
      if (x == c) i = (t = c) - 1;
    }
  }
  cout << n - t << "\n";
  for (int i = t; i < n; i++) {
    cout << arr[i] << " ";
  }
  cout << "\n";
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  solve();
  return 0;
}
