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