#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e6 + 50;
signed main() {
  ios::sync_with_stdio(false), cin.tie(0);
  ;
  long long n, p;
  cin >> n >> p;
  vector<long long> a(n);
  for (long long i = 0; i < n; ++i) cin >> a[i];
  sort((a).begin(), (a).end());
  long long mn = -1, mx = 1e9;
  for (long long i = 0; i < n; ++i) {
    mn = max(mn, a[i] - i);
  }
  for (long long i = p - 1; i < n; ++i) {
    mx = min(mx, a[i] - i + p - 2);
  }
  vector<long long> ans;
  for (long long i = mn; i <= mx; ++i) ans.push_back(i);
  cout << ans.size() << '\n';
  for (long long &c : ans) cout << c << ' ';
}
