#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
long long n, p, a[N], C[N], st, End;
void in() {
  cin >> n >> p;
  for (long long i = 0; i <= n - 1; i++) cin >> a[i];
  sort(a, a + n);
}
long long bns(long long lim) {
  long long low = 0, high = n - 1, res = -1;
  while (low <= high) {
    long long mid = (low + high) / 2;
    if (a[mid] <= lim)
      low = mid + 1, res = mid;
    else
      high = mid - 1;
  }
  return res + 1;
}
long long bns_low() {
  long long low = 1, high = 1e15, res = -1;
  while (low <= high) {
    long long mid = (low + high) / 2;
    bool kq = true;
    for (long long i = 0; i <= n - 1; i++)
      if (mid + i >= a[i])
        ;
      else
        kq = false;
    if (kq)
      high = mid - 1, res = mid;
    else
      low = mid + 1;
  }
  return res;
}
long long bns_high() {
  long long low = st, high = 1e15, res = -1;
  while (low <= high) {
    long long mid = (low + high) / 2;
    bool kq = true;
    for (long long i = 0; i <= n - 1; i++) {
      C[i] = bns(i + mid) - i;
      if (C[i] <= 0 || C[i] >= p) kq = false;
    }
    if (kq)
      low = mid + 1, res = mid;
    else
      high = mid - 1;
  }
  return res;
}
void process() {
  st = bns_low();
  End = bns_high();
  if (st == -1 || End == -1) {
    cout << 0;
    exit(0);
  }
  cout << End - st + 1 << '\n';
  for (long long i = st; i <= End; i++) cout << i << ' ';
}
int main() {
  if (fopen("trash.inp", "r"))
    freopen("trash.inp", "r", stdin), freopen("trash.out", "w", stdout);
  ios ::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  in();
  process();
}
