#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, p, a[N], lb, ub;
int main() {
  scanf("%d%d", &n, &p);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    ub = max(ub, a[i]);
  }
  sort(a, a + n);
  for (int i = 0; i < n; ++i) {
    lb = max(lb, a[i] - i);
  }
  for (int i = 0; p + i - 1 < n; ++i) {
    ub = min(ub, a[p + i - 1] - i - 1);
  }
  if (lb > ub)
    puts("0");
  else {
    printf("%d\n", ub - lb + 1);
    for (int i = lb; i <= ub; ++i) {
      printf("%d ", i);
    }
  }
  return 0;
}
