#include <bits/stdc++.h>
using namespace std;
long long a[100000 + 7], n, p;
bool good(long long b) {
  long long k = 0, maxx = -1, i;
  for (i = 1; i <= n; i++) {
    if (a[i] <= b) {
      k++;
      if (k > maxx) maxx = k;
    } else {
      k--;
      if (k < 0) return false;
      b++;
      i--;
    }
  }
  if (maxx < p)
    return true;
  else
    return false;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  vector<long long> ans;
  long long N, i, j, m, b, k, left, right, L, R, M, maxx = -1, minn = INT_MAX;
  cin >> n >> p;
  for (i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  k = 0;
  b = a[1];
  for (i = 1; i <= n; i++) {
    if (a[i] <= b) {
      k++;
      if (k > maxx) maxx = k;
    } else {
      k -= a[i] - a[i - 1];
      minn = min(minn, k);
      b += a[i] - a[i - 1];
      i--;
    }
  }
  left = max({a[1], a[n] - (n - 1), a[1] - minn});
  if (!good(left)) {
    cout << 0;
    return 0;
  }
  L = left;
  R = 1e9 + 1;
  while (R - L > 1) {
    M = (L + R) / 2;
    if (good(M))
      L = M;
    else
      R = M;
  }
  right = L;
  cout << right - left + 1 << endl;
  for (i = left; i <= right; i++) cout << i << " ";
}
