#include <bits/stdc++.h>
using namespace std;
class Hash {
 public:
  vector<unsigned long long> s;
  vector<unsigned long long> b, v;
  unsigned long long mod, base;
  Hash(vector<unsigned long long> ss, unsigned long long bbase) {
    s = ss;
    base = bbase;
    v.resize(((int)(s.size())) + 1);
    b.resize(1111111);
    b[0] = 1;
    for (int i(1), _b(1111111); i < _b; ++i) {
      b[i] = (b[i - 1] * base);
    }
    v[0] = 1;
    for (int i(1), _b(((int)(v.size()))); i < _b; ++i) {
      v[i] = (v[i - 1] + b[i] * s[i - 1]);
    }
  }
  unsigned long long get(int st, int en) {
    if (st > en) return 0;
    return (v[en] - v[st - 1]) * (b[((int)(s.size())) - en]);
  }
};
string s1, s2;
vector<unsigned long long> v;
unsigned long long n, t1, t2, t3, h1, h2;
map<int, vector<unsigned long long> > id;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i(0), _n(n); i < _n; ++i) {
    cin >> t1;
    v.push_back(t1);
    id[t1].push_back(i);
  }
  Hash h(v, 3137);
  set<pair<int, int> > st;
  for (int i(0), _n(n); i < _n; ++i) {
    for (__typeof((id[v[i]]).begin()) j = (id[v[i]]).begin();
         j != (id[v[i]]).end(); ++j) {
      if ((*j) <= i) continue;
      t1 = *j - i;
      h1 = h.get(i + 1, *j);
      t2 = *j + t1;
      if (t2 > n) continue;
      h2 = h.get(*j + 1, t2);
      if (h1 == h2) {
        st.insert(make_pair(t1, i));
      }
    }
  }
  t1 = 0;
  while (((int)(st.size()))) {
    pair<int, int> p = *st.begin();
    st.erase(st.begin());
    if (p.second < t1) continue;
    t1 = p.second + p.first;
  }
  cout << n - t1 << endl;
  for (int i(t1), _b(n); i < _b; ++i) {
    cout << v[i] << " ";
  }
}
