#include <bits/stdc++.h>
using namespace std;
const long long INF = 1 << 28;
const long long LINF = 1ll << 61;
int n, lg2[100111];
struct suffix_array {
  int b[100111], a[100111], sa[100111], nsa[100111], rk[100111], nrk[100111];
  int lcp[100111];
  int tab[20][100111];
  void makeb() {
    memset(b, 0, sizeof(b));
    for (int i = 0; i < n; i++) b[rk[i]]++;
    for (int i = 1; i <= n; i++) b[i] += b[i - 1];
  }
  pair<int, int> tmp[100111];
  void construct() {
    memset(tab, 0, sizeof(tab));
    memset(lcp, 0, sizeof(lcp));
    for (int i = 0; i < n; i++) tmp[i] = make_pair(a[i], i);
    sort(tmp, tmp + n);
    for (int i = 0; i < n; i++) sa[i] = tmp[i].second;
    rk[sa[0]] = 0;
    for (int i = 1; i < n; i++)
      rk[sa[i]] = rk[sa[i - 1]] + (a[sa[i - 1]] < a[sa[i]]);
    for (int k = 1; k < n; k <<= 1) {
      makeb();
      for (int i = n - 1; i >= 0; i--)
        if (sa[i] >= k) nsa[--b[rk[sa[i] - k]]] = sa[i] - k;
      for (int i = n - 1; i >= 0; i--)
        if (sa[i] >= n - k) nsa[--b[rk[sa[i]]]] = sa[i];
      nrk[nsa[0]] = 0;
      for (int i = 1; i < n; i++)
        nrk[nsa[i]] =
            nrk[nsa[i - 1]] +
            (make_pair(rk[nsa[i - 1]],
                       nsa[i - 1] + k >= n ? -1 : rk[nsa[i - 1] + k]) <
             make_pair(rk[nsa[i]], nsa[i] + k >= n ? -1 : rk[nsa[i] + k]));
      swap(rk, nrk);
      swap(sa, nsa);
    }
    for (int i = 0; i < n; i++) rk[sa[i]] = i;
    int h = 0;
    for (int i = 0; i < n; i++) {
      if (h > 0) h--;
      if (rk[i] == 0) continue;
      int j = sa[rk[i] - 1];
      while (i + h < n && j + h < n && a[i + h] == a[j + h]) h++;
      lcp[rk[i] - 1] = h;
    }
    for (int i = 0; i < n; i++) tab[0][i] = lcp[i];
    for (int i = 1; i < 20; i++) {
      for (int j = 0; j <= n - (1 << i); j++) {
        tab[i][j] = min(tab[i - 1][j], tab[i - 1][j + (1 << (i - 1))]);
      }
    }
  }
  int query(int x, int y) {
    x = rk[x];
    y = rk[y];
    if (x > y) swap(x, y);
    int t = lg2[y - x];
    return min(tab[t][x], tab[t][y - (1 << t)]);
  }
} sa1, sa2;
int a[100111];
int main() {
  lg2[1] = 0;
  for (int i = 2; i <= 100001; i++) lg2[i] = lg2[i >> 1] + 1;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < n; i++) {
    sa1.a[i] = a[i];
    sa2.a[n - i - 1] = a[i];
  }
  sa1.construct();
  sa2.construct();
  int ans = 0;
  for (int i = 1; i <= n / 2; i++) {
    for (int j = 0; j + i < n; j += i) {
      if (j < ans) continue;
      int l1 = sa1.query(j, j + i);
      int l2 = min(j - ans + 1, sa2.query(n - j - 1, n - (j + i) - 1));
      int l = l1 + l2 - 1;
      if (l >= i) {
        ans = j - l2 + i + 1;
      }
    }
  }
  printf("%d\n", n - ans);
  for (int i = ans; i < n; i++) printf("%d ", a[i]);
  return 0;
}
