#include <bits/stdc++.h>
using namespace std;
const int XL = 100 * 1000;
int main() {
  int n;
  cin >> n;
  int a[XL];
  bool used[XL];
  for (int i = 0; i < n; i++) {
    used[i] = false;
  }
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n / 2; i++) {
    swap(a[i], a[n - 1 - i]);
  }
  int mass[XL];
  for (int i = 0; i < n; i++) {
    if (used[a[i]] == false) {
      mass[i] = a[i];
      used[a[i]] = true;
    }
  }
  int b[XL]{};
  for (int i = 0; i < n; i++) {
    if (mass[i] != 0) {
      b[i] = mass[i];
    }
  }
  int q = 0;
  for (int i = 0; i < n; i++) {
    if (b[i] != 0) {
      q++;
    }
  }
  int x = 0;
  int v[XL];
  for (int i = 0; i < n; i++) {
    if (b[i] == 0) {
      x++;
    }
    if (b[i] != 0) {
      v[i - x] = b[i];
    }
  }
  cout << q << endl;
  for (int i = 0; i < q / 2; i++) {
    swap(v[i], v[q - 1 - i]);
  }
  for (int i = 0; i < q; i++) {
    cout << v[i] << "\t";
  }
}
