#include <bits/stdc++.h>
using namespace std;
long long data[500000];
int main() {
  ios::sync_with_stdio(false);
  long long n, p;
  cin >> n >> p;
  for (long long i = 1; i <= n; i++) cin >> data[i];
  sort(data + 1, data + 1 + n);
  long long l = 0, r = 1e10 + 100;
  for (long long i = 1; i <= n; i++) l = max(data[i] - i + 1, l);
  for (long long i = 1; p + i - 1 <= n; i++) r = min(data[p + i - 1] - i, r);
  cout << max(0ll, r - l + 1) << endl;
  while (l <= r) cout << l++ << ' ';
  cout << endl;
  return 0;
}
