#include <bits/stdc++.h>
// #include <stdio.h>
#define ss second
#define ff first
#define sz size()
#define end end() // если не работет сорт или реверс и тд
#define rall(x) x.rbegin(), x.rend()    
#define all(x) (x).begin(), (x).end
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define popf pop_front()
#define popb pop_back()
#define pll pair <ll, ll>
#define pii pair <int, int>
#define sss ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
 
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
 
const long long  MOD = 1e9 + 7; //1000000007;
const long long N = 5e6 + 5;
const long long INF = 1e9;
const long long M = 3e3 + 5;
const double EPS = 1e-6;
// mid = l + (r - l) / 2;
void file(string s){
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}
//stoi = StringTOInt;
//vector<vector<int>> a(n, vector<int>(n));
 
signed main(){
    sss
    // file("");
    int n, m; cin >> n >> m;
    vector <int> a(m);
    map <int, int> mp;
    int mn = 12301023;
    int mx = -123213;
    for(int i = 0;i < m;i++){
        cin >> a[i];
        mp[a[i]]++;
        mn = min(mn, a[i]);
        mx = max(mx, a[i]);
    }
    int cnt = 0;
    vector <int> ans;
    for(int i = mn;i <= mx;i++){
        if(mp[i] > 1){
            cnt++;
            ans.pb(i);
        }
    }
    cout << cnt << "\n";
    for(int i = 0;i < ans.sz;i++) cout << ans[i] << " ";
    return 0;
}