#include <bits/stdc++.h>
using namespace std;
const long long sz = 1e5 + 10;
long long ara[sz], n, p;
;
bool isValid(long long now) {
  long long ptr = 1;
  for (long long i = 1; i <= n; ++i) {
    while (ptr <= n && ara[ptr] <= now) ptr++;
    if (ptr - i >= p) return 0;
    now++;
  }
  return 1;
}
int main() {
  cin >> n >> p;
  for (long long i = 1; i <= n; ++i) scanf("%lld", &ara[i]);
  sort(ara + 1, ara + n + 1);
  long long start = 1, now = start;
  for (long long i = 1; i <= n; ++i) {
    if (now < ara[i]) {
      long long diff = ara[i] - now;
      now += diff, start += diff;
    }
    now++;
  }
  long long lo = start, hi = 1e9, stop = -1;
  while (lo <= hi) {
    long long mid = lo + hi >> 1;
    if (isValid(mid)) {
      stop = mid;
      lo = mid + 1;
    } else
      hi = mid - 1;
  }
  cout << max(0LL, stop - start + 1) << '\n';
  for (long long i = start; i <= stop; i += 1) {
    if (i != start) printf(" ");
    printf("%lld", i);
  }
  if (stop != -1) printf("\n");
  return 0;
}
