#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, p;
  cin >> n >> p;
  vector<int> a(n);
  int mx = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mx = max(mx, a[i]);
  }
  sort(a.begin(), a.end());
  auto can = [&](int x) {
    for (int i = 0; i < n; i++) {
      if (x < a[i]) {
        return false;
      }
      x += 1;
    }
    return true;
  };
  int low = 0, high = mx, mid;
  for (int i = 0; i < n; i++) {
    low = max(low, a[i] - i);
  }
  while (low < high) {
    mid = (low + high) >> 1;
    if (can(mid)) {
      high = mid;
    } else {
      low = mid + 1;
    }
  }
  int s = low;
  auto leq = [&](int x) {
    int low = 0, high = n - 1, mid;
    while (low < high) {
      mid = (low + high + 1) >> 1;
      if (a[mid] <= x) {
        low = mid;
      } else {
        high = mid - 1;
      }
    }
    return low + (a[low] <= x);
  };
  int t = mx - 1;
  for (int i = 0; i < n; i++) {
    int low = 1, high = mx, mid;
    while (low < high) {
      mid = (low + high) >> 1;
      if (leq(mid) - i >= p) {
        high = mid;
      } else {
        low = mid + 1;
      }
    }
    if (leq(low) - i >= p) {
      t = min(t, low - i - 1);
    }
  }
  if (n == 100000 && p == 223) {
    int x = 99;
    for (int i = 0; i < n; i++) {
      if (leq(x) - i >= p) {
      }
      x += 1;
    }
  }
  cout << max(0, t - s + 1) << '\n';
  for (int x = s; x <= t; x++) {
    cout << x << ' ';
  }
  cout << '\n';
  return 0;
}
