#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, p;
  cin >> n >> p;
  vector<int> a(n);
  for (auto &x : a) cin >> x;
  sort(a.begin(), a.end());
  int low = 0;
  int high = 1000000000;
  while (low < high) {
    int target = (low + high) / 2;
    bool good = true;
    for (int j = 0; j < n; j++) {
      int possibles = min(j + 1, max(0, (target + j) - a[j] + 1));
      if (possibles == 0) {
        good = false;
        break;
      }
    }
    if (!good)
      low = target + 1;
    else
      high = target;
  }
  int ans_low = high;
  low = 0;
  high = 1000000000;
  while (low < high) {
    int target = (low + high + 1) / 2;
    bool good = true;
    for (int j = 0; j < n; j++) {
      int possibles = min(j + 1, max(0, (target + j) - a[j] + 1));
      if (possibles >= p) {
        good = false;
        break;
      }
    }
    if (!good)
      high = target - 1;
    else
      low = target;
  }
  int ans_high = high;
  cout << max(0, ans_high - ans_low + 1) << endl;
  for (int i = ans_low; i <= ans_high; i++) cout << i << " ";
  cout << endl;
  return 0;
}
