#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)1e6 + 7;
const int INF = (int)10007;
int a[MAXN];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, p;
  cin >> n >> p;
  for (int i = (int)1; i <= (int)n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + 1 + n);
  int mn = 0;
  for (int i = (int)1; i <= (int)n; i++) {
    mn = max(a[i] - i + 1, mn);
  }
  int mx = 1000000007;
  for (int i = (int)0; i <= (int)n - p; i++) {
    mx = min(mx, a[i + p] - i - 1);
  }
  if (mx < mn)
    cout << 0 << endl << endl;
  else {
    cout << mx - mn + 1 << endl;
    for (int i = (int)mn; i <= (int)mx; i++) cout << i << " ";
  }
}
