#include<iostream>
#include<cstring>
using namespace std;
int a[1000010];
bool vis[100010];
int b[100010];
int main()
{
int c,n;
while(cin >> c >> n)
{
int k = 0;
memset(vis,0,sizeof(vis));
for(int i = 0; i < n; i++)
cin >> a[i];
for(int i = n-1; i >= 0; i--)
{
if(!vis[a[i]])
{
b[k++] = a[i];
vis[a[i]] = 1;
}
}
cout << k << endl;
for(int i = k-1; i >= 0; i--)
{
if(i == k-1) cout << b[i];
else cout << " " << b[i];
}
cout << endl;
}
}
#include<cstring>
using namespace std;
int a[1000010];
bool vis[100010];
int b[100010];
int main()
{
int c,n;
while(cin >> c >> n)
{
int k = 0;
memset(vis,0,sizeof(vis));
for(int i = 0; i < n; i++)
cin >> a[i];
for(int i = n-1; i >= 0; i--)
{
if(!vis[a[i]])
{
b[k++] = a[i];
vis[a[i]] = 1;
}
}
cout << k << endl;
for(int i = k-1; i >= 0; i--)
{
if(i == k-1) cout << b[i];
else cout << " " << b[i];
}
cout << endl;
}
}