#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 7;
int a[MAXN], n, p, lim = 0;
bool check(int val) {
  for (int i = 1; i <= n; ++i)
    if (val + i - 1 < a[i]) return 0;
  return 1;
}
bool valid(int val) {
  int sta = 0;
  for (int i = 0; i < n; ++i) {
    while (sta + 1 <= n && val + i >= a[sta + 1]) ++sta;
    if (sta - i >= p) return 0;
  }
  return 1;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> p;
  for (int i = 1; i <= n; ++i) cin >> a[i], lim = max(lim, a[i]);
  sort(a + 1, a + 1 + n);
  int l = 0, r = lim, sta = -1;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (check(mid))
      sta = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  l = sta, r = lim;
  int fin = sta - 1;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (valid(mid))
      fin = mid, l = mid + 1;
    else
      r = mid - 1;
  }
  cout << fin - sta + 1 << '\n';
  for (int i = sta; i <= fin; ++i) cout << i << ' ';
  return 0;
}
