#include <bits/stdc++.h>
const long long LL_INF = (long long)2e18 + 5;
using namespace std;
void solve() {
  long long n, k;
  cin >> n >> k;
  vector<long long> v(n);
  {
    for (auto &i : v) cin >> i;
  }
  sort(v.begin(), v.end());
  long long mx = 0;
  for (long long i = (long long)(0); i < (long long)(n); i++)
    mx = max(v[i] - i, mx);
  long long end = 0x3f3f3f3f;
  for (long long i = (long long)(k - 1); i < (long long)(n); i++) {
    end = min(end, v[i] - (i - k + 1));
  }
  cout << max(0ll, end - mx) << '\n';
  for (long long i = (long long)(mx); i < (long long)(end); i++)
    cout << i << ' ';
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
}
