#include <bits/stdc++.h>
using namespace std;
int Rank[30][150000];
int Suffix[150000];
int Lcp[150000];
struct entry {
  int A[2];
  int pos;
} Temp[150000];
long long str[150000];
int N, step, cnt;
bool way(entry x, entry y) {
  return x.A[0] < y.A[0] or (x.A[0] == y.A[0] and x.A[1] < y.A[1]);
}
void Build_Suffix_Array() {
  for (int i = 0; i < N; i++) Rank[0][i] = str[i] - 'a';
  for (step = 1, cnt = 1; (cnt >> 1) < N; step++, (cnt <<= 1)) {
    for (int i = 0; i < N; i++) {
      Temp[i].A[0] = Rank[step - 1][i];
      Temp[i].A[1] = (i + cnt < N) ? Rank[step - 1][i + cnt] : -1000000007;
      Temp[i].pos = i;
    }
    sort(Temp, Temp + N, way);
    for (int i = 0; i < N; i++) {
      Rank[step][Temp[i].pos] = (i > 0 and Temp[i].A[0] == Temp[i - 1].A[0] and
                                 Temp[i].A[1] == Temp[i - 1].A[1])
                                    ? Rank[step][Temp[i - 1].pos]
                                    : i;
    }
  }
  for (int i = 0; i < N; i++) {
    Suffix[i] = Temp[i].pos;
  }
  step--;
}
void Build_Lcp_Array() {
  for (int i = 0, l = 0; i < N; i++) {
    if (Rank[step][i] != N - 1) {
      for (int j = Suffix[Rank[step][i] + 1];
           j + l < N and i + l < N and str[i + l] == str[j + l];)
        l++;
      Lcp[Rank[step][i]] = l;
      if (l) l--;
    }
  }
}
int lcp(int x, int y) {
  if (x == y) return N - x;
  int ret = 0;
  for (int i = step; i >= 0 && x < N && y < N; i--) {
    if (Rank[i][x] == Rank[i][y]) x += (1 << i), y += (1 << i), ret += (1 << i);
  }
  return ret;
}
int RMQ[30][150000];
void Build_RMQ() {
  for (int i = 0; i < N; i++) RMQ[0][i] = Lcp[i];
  for (int j = 1; j <= step; j++) {
    for (int i = 0; i < N - 1; i++) {
      if (i + (1 << j) >= N - 1)
        RMQ[j][i] = 1000000007;
      else {
        RMQ[j][i] =
            ((RMQ[j - 1][i]) < (RMQ[j][i + (1 << j)]) ? RMQ[j - 1][i]
                                                      : RMQ[j][i + (1 << j)]);
      }
    }
  }
}
int RMQ_LCP(int x, int y) {
  int a, b;
  a = Rank[step][x];
  b = Rank[step][y] - 1;
  if (a > b) swap(a, b);
  int tmp = log2(b - a + 1);
  int ret = ((RMQ[tmp][a]) < (RMQ[tmp][b - (1 << tmp) + 1])
                 ? RMQ[tmp][a]
                 : RMQ[tmp][b - (1 << tmp) + 1]);
  return ret;
}
char Query[150000];
bool Present(int left, int right) {
  if (left > right) return false;
  int mid = (right + left) / 2;
  int pos = Suffix[mid];
  int k = strlen(Query);
  k = ((k) < (N - pos + 1) ? k : N - pos + 1);
  for (int i = 0; i < k; i++) {
    if (Query[i] > str[pos + i])
      return Present(mid + 1, right);
    else if (Query[i] < str[pos + i])
      return Present(left, mid - 1);
  }
  if (N - pos + 1 < strlen(Query)) return Present(mid + 1, right);
  return true;
}
std::map<long long, std::vector<int> > mp;
std::vector<pair<int, int> > lsit;
long long arr[140000];
int main() {
  int n, i;
  long long temp;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%I64d", &arr[i]);
    str[i] = arr[i];
    mp[arr[i]].push_back(i);
  }
  N = n;
  Build_Suffix_Array();
  Build_Lcp_Array();
  for (i = 0; i < n; i++) {
    for (std::vector<int>::iterator it = mp[arr[i]].begin();
         it != mp[arr[i]].end(); it++) {
      if (*it <= i) continue;
      temp = lcp(i, *it);
      if (temp >= *it - i) {
        lsit.push_back(pair<int, int>(*it - i, i));
        break;
      }
    }
  }
  sort(lsit.begin(), lsit.end());
  int limits = 0;
  for (i = 0; i < lsit.size(); i++) {
    if (lsit[i].second >= limits) {
      limits = lsit[i].second + lsit[i].first;
    }
  }
  printf("%d\n", n - limits);
  for (i = limits; i < n; i++) printf("%I64d ", arr[i]);
  printf("\n");
}
