#include <bits/stdc++.h>
using namespace std;
const long long M = 1e7 + 10;
long long prime[M];
void precompute() {
  for (long long i = 2; i < M; i++) {
    if (!prime[i]) {
      for (long long j = 1; i * j < M; j++) prime[i * j] = i;
    }
  }
}
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long a[200050] = {0};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t, i, j, n, m, k, q, temp, x, y, p;
  {
    long long count = 0;
    bool flag = 0;
    cin >> n >> p;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    sort(a, a + n);
    long long minx = 0;
    for (int i = 0; i < n; i++) {
      minx = max(minx, a[i] - i);
    }
    std::vector<long long> ans;
    long long maxx = a[n - 1] + 1;
    long long j = 0;
    for (i = p - 1; i < n; i++) {
      maxx = min(maxx, a[i] - j);
      j++;
    }
    for (i = minx; i < maxx; i++) {
      ans.push_back(i);
    }
    cout << ans.size() << endl;
    for (auto it : ans) {
      cout << it << " ";
    }
    cout << endl;
    string s;
  }
  return 0;
}
