#include <bits/stdc++.h>
using namespace std;
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;
typedef unsigned long long int ull;
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define mp make_pair
ll arr[100000];
ll n,p;
ll bs(ll key){
ll l=0, r=(n-1),mid,ans=0;
while(l<=r){
mid=(l+r)/2;
if(arr[mid]==key){
mid++;
while(mid<n && arr[mid]==key){
mid++;
}
return mid;
}else if(arr[mid]>key){
r=mid-1;
}else{
ans=mid+1;
l=mid+1;
}
}
return ans;
}
bool check(ll x){
if(bs(x)<p){
return 1;
}
return 0;
}
int main(){
fast;
int test=1;
//cin >> test;
while(test--){
cin >> n >> p;
ll minv=1000000001,maxv=-1;
for(ll i=0 ; i<n ; i++){
cin >> arr[i];
maxv=max(maxv,arr[i]);
minv=min(minv,arr[i]);
}
sort(arr,arr+n);
ll sum=0,temp=minv;
for(int i=1 ; i<n ; i++){
sum+=(arr[i]-arr[i-1]-1);
temp=max(temp,minv+sum);
}
minv=temp;
ll ans=-1;
ll l=minv,r=maxv,mid;
while(l<=r){
mid=(l+r)/2;
if(!check(mid)){
r=mid-1;
}else{
l=mid+1;
ans=mid;
}
}
if(ans==-1){
cout << 0 << endl;
return 0;
}
cout << ans-minv+1 << endl;
for(ll i=minv ; i<=ans ; i++){
cout << i << " ";
}
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgZml4KGYsbikgc3RkOjpmaXhlZDw8c3RkOjpzZXRwcmVjaXNpb24obik8PGYKI2RlZmluZSB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ayhsbCB4KXsKICAgIGlmKGJzKHgpPHApewogICAgICAgIHJldHVybiAxOwogICAgfQogICAgcmV0dXJuIDA7Cn0KCmludCBtYWluKCl7CglmYXN0OwoJaW50IHRlc3Q9MTsKCS8vY2luID4+IHRlc3Q7Cgl3aGlsZSh0ZXN0LS0pewoJICAgIGNpbiA+PiBuID4+IHA7CgkgICAgbGwgbWludj0xMDAwMDAwMDAxLG1heHY9LTE7CgkgICAgZm9yKGxsIGk9MCA7IGk8biA7IGkrKyl7CgkgICAgICAgIGNpbiA+PiBhcnJbaV07CgkgICAgICAgIG1heHY9bWF4KG1heHYsYXJyW2ldKTsKCSAgICAgICAgbWludj1taW4obWludixhcnJbaV0pOwoJICAgIH0KCSAgICBzb3J0KGFycixhcnIrbik7CgkgICAgbGwgc3VtPTAsdGVtcD1taW52OwoJICAgIGZvcihpbnQgaT0xIDsgaTxuIDsgaSsrKXsKCSAgICAgICAgc3VtKz0oYXJyW2ldLWFycltpLTFdLTEpOwoJICAgICAgICB0ZW1wPW1heCh0ZW1wLG1pbnYrc3VtKTsKCSAgICB9CgkgICAgbWludj10ZW1wOwogICAgICAgIGxsIGFucz0tMTsKCSAgICBsbCBsPW1pbnYscj1tYXh2LG1pZDsKCSAgICB3aGlsZShsPD1yKXsKCSAgICAgICAgbWlkPShsK3IpLzI7CgkgICAgICAgIGlmKCFjaGVjayhtaWQpKXsKCSAgICAgICAgICAgIHI9bWlkLTE7CgkgICAgICAgIH1lbHNlewoJICAgICAgICAgICAgbD1taWQrMTsKCSAgICAgICAgICAgIGFucz1taWQ7CgkgICAgICAgIH0KCSAgICB9CgkgICAgaWYoYW5zPT0tMSl7CgkgICAgICAgIGNvdXQgPDwgMCA8PCBlbmRsOwoJICAgICAgICByZXR1cm4gMDsKCSAgICB9CgkgICAgY291dCA8PCBhbnMtbWludisxIDw8IGVuZGw7CgkgICAgZm9yKGxsIGk9bWludiA7IGk8PWFucyA7IGkrKyl7CgkgICAgICAgIGNvdXQgPDwgaSA8PCAiICI7CgkgICAgfQoJfQoJcmV0dXJuIDA7Cn0=