#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, p;
  cin >> n >> p;
  vector<int> a(n);
  for (int& i : a) {
    cin >> i;
  }
  int mn = 0;
  sort(a.begin(), a.end());
  for (int i = 0; i < n; ++i) {
    mn = max(a[i] - i, mn);
  }
  auto check = [&](int x) {
    vector<int> pre(n + 1, 0);
    for (int i = 0; i < n; ++i) {
      int lst = max(0, a[i] - x);
      assert(lst >= 0 && lst <= i);
      ++pre[lst];
      --pre[i + 1];
    }
    for (int i = 1; i < n; ++i) {
      pre[i] += pre[i - 1];
    }
    return *max_element(pre.begin(), pre.end()) < p;
  };
  int l = mn - 1, r = a.back();
  while (l < r) {
    int mid = (l + r + 1) / 2;
    if (check(mid))
      l = mid;
    else
      r = mid - 1;
  }
  cout << l - mn + 1 << '\n';
  for (int i = mn; i <= l; ++i) {
    cout << i << " ";
  }
  cout << '\n';
}
