#include <bits/stdc++.h>
using namespace std;
long long calmn(long long arr[], long long n, long long cx) {
  long long mn = 0, idx = 0;
  while (idx < n && arr[idx] <= cx) idx++, mn++;
  long long cur = mn;
  while (idx < n) {
    cur--, cx++;
    while (idx < n && arr[idx] <= cx) idx++, cur++;
    mn = min(mn, cur);
    if (cur == 0) break;
  }
  return mn;
}
long long calmx(long long arr[], long long n, long long cx) {
  long long mn = 0, idx = 0;
  while (idx < n && arr[idx] <= cx) idx++, mn++;
  long long cur = mn;
  while (idx < n) {
    cur--, cx++;
    while (idx < n && arr[idx] <= cx) idx++, cur++;
    mn = max(mn, cur);
    if (cur == 0) return 0;
  }
  return mn;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, p;
  cin >> n >> p;
  long long arr[n];
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + n);
  long long lw = arr[0] - 1, hg = arr[n - 1];
  while (lw < hg) {
    long long md = (lw + hg) / 2;
    if (calmn(arr, n, md) > 0) {
      hg = md - 1;
    } else {
      if (lw == md) break;
      lw = md;
    }
  }
  long long sx = calmn(arr, n, hg) == 0 ? hg : lw;
  lw = arr[0] - 1, hg = arr[n - 1];
  while (lw < hg) {
    long long md = (lw + hg) / 2;
    if (calmx(arr, n, md) < p) {
      lw = md + 1;
    } else {
      if (hg == md) break;
      hg = md;
    }
  }
  long long sy = calmx(arr, n, lw) >= p ? lw : hg;
  vector<long long> ans;
  for (long long i = sx + 1; i < sy; i++) ans.push_back(i);
  cout << ans.size() << "\n";
  for (long long e : ans) cout << e << " ";
  return 0;
}
