#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int wa[maxn], wb[maxn], wv[maxn], Ws[maxn];
int cmp(int *r, int a, int b, int l) {
  return r[a] == r[b] && r[a + l] == r[b + l];
}
void da(const int *r, int *sa, int n, int m) {
  int i, j, p, *x = wa, *y = wb, *t;
  for (i = 0; i < m; i++) Ws[i] = 0;
  for (i = 0; i < n; i++) Ws[x[i] = r[i]]++;
  for (i = 1; i < m; i++) Ws[i] += Ws[i - 1];
  for (i = n - 1; i >= 0; i--) sa[--Ws[x[i]]] = i;
  for (j = 1, p = 1; p < n; j *= 2, m = p) {
    for (p = 0, i = n - j; i < n; i++) y[p++] = i;
    for (i = 0; i < n; i++)
      if (sa[i] >= j) y[p++] = sa[i] - j;
    for (i = 0; i < n; i++) wv[i] = x[y[i]];
    for (i = 0; i < m; i++) Ws[i] = 0;
    for (i = 0; i < n; i++) Ws[wv[i]]++;
    for (i = 1; i < m; i++) Ws[i] += Ws[i - 1];
    for (i = n - 1; i >= 0; i--) sa[--Ws[wv[i]]] = y[i];
    for (t = x, x = y, y = t, p = 1, x[sa[0]] = 0, i = 1; i < n; i++)
      x[sa[i]] = cmp(y, sa[i - 1], sa[i], j) ? p - 1 : p++;
  }
  return;
}
int sa[maxn], Rank[maxn], height[maxn];
void calheight(const int *r, int *sa, int n) {
  int i, j, k = 0;
  for (i = 1; i <= n; i++) Rank[sa[i]] = i;
  for (i = 0; i < n; height[Rank[i++]] = k)
    for (k ? k-- : 0, j = sa[Rank[i] - 1]; r[i + k] == r[j + k]; k++)
      ;
  return;
}
int b[maxn];
int a[maxn];
int LOG[maxn];
int dp[20][maxn];
int Min(int a, int b) {
  if (a < b) return a;
  return b;
}
void RMQ(int m) {
  int i, j;
  LOG[0] = -1;
  for (i = 1; i <= m; i++) LOG[i] = LOG[i >> 1] + 1;
  for (i = 1; i <= m; i++) dp[0][i] = height[i];
  for (j = 1; j <= LOG[m]; j++) {
    int limit = m + 1 - (1 << j);
    for (i = 1; i <= limit; i++) {
      int x = i + (1 << j >> 1);
      dp[j][i] = Min(dp[j - 1][x], dp[j - 1][i]);
    }
  }
}
int lcp(int l, int r) {
  l = Rank[l];
  r = Rank[r];
  if (l > r) {
    int tmp = l;
    l = r;
    r = tmp;
  }
  l++;
  int m = LOG[r - l + 1];
  return Min(dp[m][l], dp[m][r - (1 << m) + 1]);
}
map<int, int> mp;
vector<int> num[maxn];
int tot;
struct Node {
  int p, len;
  Node(int p = 0, int len = 0) : p(p), len(len) {}
  bool operator<(const Node &t) const {
    if (len != t.len) return len > t.len;
    return p > t.p;
  }
};
priority_queue<Node> que;
int main() {
  int tp, t;
  int p, len;
  int n, m;
  int i, j, k;
  while (scanf("%d", &n) != EOF) {
    tot = 0;
    mp.clear();
    for (i = 0; i <= n; i++) num[i].clear();
    for (i = 0; i < n; i++) {
      scanf("%d", &tp);
      b[i] = tp;
      t = mp[tp];
      if (!t) t = mp[tp] = ++tot;
      a[i] = t;
      num[t].push_back(i);
    }
    a[n] = 0;
    da(a, sa, n + 1, tot + 1);
    calheight(a, sa, n);
    RMQ(n);
    for (i = 1; i <= tot; i++) {
      for (j = 0; j < num[i].size(); j++) {
        for (k = j + 1; k < num[i].size(); k++) {
          int x = num[i][j];
          int y = num[i][k];
          len = lcp(x, y);
          if (len < y - x) continue;
          que.push(Node(x, y - x));
        }
      }
    }
    int ans = 0;
    while (!que.empty()) {
      p = que.top().p;
      len = que.top().len;
      que.pop();
      if (ans <= p) ans = p + len;
    }
    printf("%d\n", n - ans);
    for (i = ans; i < n; i++) printf("%d ", b[i]);
    puts("");
  }
  return 0;
}
