#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   const int INF = 1e9 + 7;   const int base = 1e9;   const int MAX = 1e5;   const double EPS = 1e-9;   const double PI = acos(-1.);   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, *a, *res, j = 0;     cin >> n;     a = new int[n];     res = new int[n];     set<int> cnt;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     for (int i = n - 1; i >= 0; i--) {       if (!cnt.count(a[i])) {         cnt.insert(a[i]);         res[j] = a[i];         j++;       }     }     cout << j << endl;     for (int i = j - 1; i >= 0; i--) {       cout << res[i] <<    ;     }     return 0;   }   