#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
using namespace std;
int main() {
    long long n, m;
    cin >> n >> m;
    vector<long long> costs(m);
    for (long long i = 0; i < m; i++) {
        cin >> costs[i];
    }
    sort(costs.begin(),costs.end());
    set <long long> results;
    for (int i=0;i<m;i++) {
       if (i+n<m && costs[i]==costs[i+n-1]) {results.insert(costs[i]);}
    }

 

    cout<<results.size()<<endl;
    for (auto now : results) {
        cout <<now<< " ";
    }

    return 0;
}