#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const int maxn = 200010;
const long long Mod = 1000000007;
int a[maxn];
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  ;
  int n, p;
  cin >> n >> p;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + n + 1);
  int l = 0, r = a[n] + 2;
  for (int i = 1; i <= n; i++) {
    l = max(l, a[i] - i + 1);
  }
  for (int i = 1; i <= n; i++) {
    if (i + p - 1 > n) break;
    r = min(r, a[i + p - 1] - (i - 1) - 1);
  }
  if (l > r) {
    cout << 0 << endl;
    return 0;
  }
  cout << r - l + 1 << endl;
  for (int i = l; i <= r; i++) {
    cout << i << ' ';
  }
  cout << endl;
  return 0;
}
