#include <bits/stdc++.h>
using namespace std;
long long int pow(long long int x, long long int y, long long int m) {
  long long int res = 1;
  x = x % m;
  while (y > 0) {
    if (y & 1) res = ((res % m) * (x % m)) % m;
    y = y >> 1;
    x = ((x % m) * (x % m)) % m;
  }
  return res % m;
}
template <typename Arg1>
void ZZ(const char* name, Arg1&& arg1) {
  std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  std::cerr.write(names, comma - names) << " = " << arg1;
  ZZ(comma, args...);
}
const long long int INF = 0xFFFFFFFFFFFFFFFL;
long long int clz(unsigned long long N) {
  return N ? 64LL - __builtin_clzll(N) : -INF;
}
clock_t time_p = clock();
void abhigyan10() {
  time_p = clock() - time_p;
  cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}
long long int seed;
mt19937 rng(seed = chrono::steady_clock::now().time_since_epoch().count());
inline long long int rnd(long long int l = 0, long long int r = INF) {
  return uniform_int_distribution<long long int>(l, r)(rng);
}
const long long int mod = 1000000007;
long long int modinv(long long int x) { return pow(x, mod - 2, mod); }
vector<long long int> a;
int bs(long long int x, long long int n) {
  long long int l = 0, h = n - 1, m, ans = 0;
  while (l <= h) {
    m = (l + h) / 2;
    if (a[m] <= x) {
      l = m + 1;
      ans = max(ans, m);
    } else {
      h = m - 1;
    }
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int s = 0, t, n, p, i;
  cin >> n >> p;
  a.resize(n);
  for (i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  for (i = 0; i < n; i++) s = max(s, a[i] - i);
  t = a[n - 1];
  for (i = 0; i < n;) {
    int d = t + i;
    int u = bs(d, n) + 1 - i;
    if (u < p)
      i++;
    else
      t--;
    if (t < s) break;
  }
  cout << max(0LL, t - s + 1) << "\n";
  for (i = s; i <= t; i++) cout << i << " ";
  return 0;
}
