#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> costs(m);
    for(int i=0;i<m;i++){
        cin>>costs[i];
    }
    sort(costs.begin(), costs.end());
    int count=1;
    vector<int> possible_costs;
    possible_costs.push_back(costs[0]);
    for(int i=1;i<m;i++){
        if(costs[i]!=costs[i-1]){
            count++;
            possible_costs.push_back(costs[i]);
        }
    }
    cout<<count<<endl;
    for(int i=0;i<count;i++){
        cout<<possible_costs[i]<<" ";
    }
    cout<<endl;
    return 0;
}
