#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
long long lcm(long long x, long long y) { return x / gcd(x, y) * y; }
long long kai(long long x, long long y, long long m) {
  long long res = 1;
  for (long long i = x - y + 1; i <= x; i++) {
    res *= i;
    res %= m;
  }
  return res;
}
long long mod_pow(long long x, long long y, long long m) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) {
      res = res * x % m;
    }
    x = x * x % m;
    y >>= 1;
  }
  return res;
}
long long comb(long long x, long long y, long long m) {
  if (y > x) return 0;
  return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}
int n, p, a[100010];
vector<int> ans;
signed main() {
  cin >> n >> p;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  int mi = a[0] - 1, ma = a[n - 1];
  while (ma - mi > 1) {
    int md = (mi + ma) / 2;
    int k = 0;
    bool bl = false;
    for (int j = 0; j < n; j++) {
      while (k + 1 < n && a[k + 1] <= md + j) k++;
      if (p <= k + 1 - j) bl = true;
    }
    if (bl)
      ma = md;
    else
      mi = md;
  }
  int mi2 = a[0] - 1, ma2 = a[n - 1];
  while (ma2 - mi2 > 1) {
    int md = (mi2 + ma2) / 2;
    int k = 0;
    bool bl = false;
    for (int j = 0; j < n; j++) {
      while (k + 1 < n && a[k + 1] <= md + j) k++;
      if (k + 1 - j <= 0) bl = true;
    }
    if (bl)
      mi2 = md;
    else
      ma2 = md;
  }
  cout << max(0, ma - ma2) << endl;
  for (int i = ma2; i < ma; i++) cout << i << " ";
  cout << endl;
}
