#include <bits/stdc++.h>
using namespace std;
long long max(long long a, long long b) { return (a > b) ? a : b; }
long long min(long long a, long long b) { return (a < b) ? a : b; }
long long gcd(long long a, long long b) {
  while (1) {
    if (a == 0) return b;
    b %= a;
    if (b == 0) return a;
    a %= b;
  }
}
long long p2(long long k, long long n) {
  long long re = 1;
  while (n) {
    if (n % 2 == 1) re = (re * k);
    k *= k;
    n /= 2;
  }
  return re;
}
int main() {
  long long n, m, i, j, t, k;
  t = 1;
  for (long long ii = 0; ii < t; ii++) {
    cin >> n >> m;
    vector<long long> a(n);
    for (i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    k = 1;
    for (i = 1; i < n; i++) {
      if (a[i] == a[i - 1])
        k++;
      else {
        k = 1;
      }
      if (k == m) break;
    }
    if (i != n) {
      cout << 0 << endl;
      continue;
    }
    k = 0;
    long long m1 = 0;
    for (i = 1; i < n; i++) {
      k += a[i] - a[i - 1] - 1;
      m1 = max(m1, k);
    }
    k = m1;
    k += a[0];
    if (a[m - 1] - k <= 0) {
      cout << 0 << endl;
      continue;
    }
    long long s = a[m - 1];
    for (i = n - 1; i >= 0; i--) {
      if (i + m >= n) continue;
      s = min(s, a[i + m] - i - 1);
    }
    if (s < k) {
      cout << 0 << endl;
      continue;
    }
    cout << s - k << endl;
    for (i = k; i <= s - 1; i++) cout << i << " ";
  }
}
