#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long MOD2 = 1e9 + 9;
const long long MOD3 = 1e9 + 21;
const long long INF = 5e18;
const long double pi = acos(-1.0);
long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
inline long long mod(long long n, long long m) {
  long long ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}
long long exp(long long a, long long b, long long M) {
  long long result = 1;
  while (b > 0) {
    if (b & 1) result = mod(result * a, M);
    b >>= 1;
    a = mod(a * a, M);
  }
  return result;
}
bool confere(vector<long long> &vet, long long x) {
  for (long long &i : vet) {
    if (i > x) {
      return false;
    }
    x++;
  }
  return true;
}
long long n, k;
bool pode(vector<long long> &vet, long long x) {
  long long ini = x;
  long long used = 0;
  long long qtd;
  for (long long i = 0; i < n; i++) {
    auto it = upper_bound(vet.begin(), vet.end(), ini);
    qtd = it - vet.begin();
    qtd -= used;
    if (qtd % (k + 1) == 0) {
      return false;
    }
    used++;
    ini++;
  }
  return true;
}
void solve() {
  cin >> n >> k;
  k--;
  vector<long long> vet(n);
  for (long long &i : vet) cin >> i;
  sort(vet.begin(), vet.end());
  long long maiorx = vet[k];
  long long menorx = INF;
  long long ini = 1, fim = INF;
  while (ini <= fim) {
    long long media = (ini + fim) / 2;
    if (confere(vet, media)) {
      menorx = media;
      fim = media - 1;
    } else {
      ini = media + 1;
    }
  }
  ini = menorx, fim = maiorx;
  while (ini <= fim) {
    long long media = (ini + fim) / 2;
    if (!pode(vet, media)) {
      maiorx = media;
      fim = media - 1;
    } else {
      ini = media + 1;
    }
  }
  if (!pode(vet, menorx)) {
    cout << 0 << "\n";
    cout << "\n";
    return;
  }
  vector<long long> res;
  for (long long i = menorx; i < maiorx; i++) {
    res.push_back(i);
  }
  cout << res.size() << "\n";
  for (long long &i : res) cout << i << ' ';
  cout << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long t = 1;
  while (t--) solve();
}
