#include <bits/stdc++.h>
using namespace std;
int a[1000000];
int main() {
  int n, p;
  cin >> n >> p;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a, a + n);
  int minx = 1;
  for (int i = 0; i < n; ++i) {
    minx = max(minx, a[i] - i);
  }
  int maxx = INT32_MAX;
  int j = n - 1;
  vector<int> x;
  while (j >= 0) {
    if (n - (n - j - 1) < p) break;
    maxx = min(a[j] + p - n - 1 + (n - 1 - j), maxx);
    int aa = a[j];
    while (a[j] == aa) j--;
  }
  cout << max(0, maxx - minx + 1) << endl;
  for (int i = minx; i <= maxx; ++i) {
    cout << i << " ";
  }
}
