#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, p;
  cin >> n >> p;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  vector<long long> ans;
  long long left = 0, right = 1000000001, middle;
  while (left < right - 1) {
    middle = (left + right) / 2;
    long long score = middle, ptr = 0, won = 0, flag = 1;
    for (int j = 0; j < n; j++) {
      while (ptr < n && a[ptr] <= score) {
        ptr++;
        won++;
      }
      if (won >= p) {
        flag = 0;
        break;
      }
      if (won == 0) break;
      won--;
      score++;
    }
    if (!flag)
      right = middle;
    else
      left = middle;
  }
  long long ans2 = left;
  left = 0;
  right = 1000000001;
  while (left < right - 1) {
    middle = (left + right) / 2;
    long long score = middle, ptr = 0, won = 0, flag = 1;
    for (int j = 0; j < n; j++) {
      while (ptr < n && a[ptr] <= score) {
        ptr++;
        won++;
      }
      if (won == 0) {
        flag = 0;
        break;
      }
      won--;
      score++;
    }
    if (!flag)
      left = middle;
    else
      right = middle;
  }
  long long ans1 = right;
  cout << max(ans2 - ans1 + 1, (long long)0) << endl;
  for (long long i = ans1; i <= ans2; i++) cout << i << " ";
}
