#include <bits/stdc++.h>
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int INF = 2e9;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, p;
  cin >> n >> p;
  vector<int> a(n);
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  sort((a).begin(), (a).end());
  int l = -INF, r = INF;
  for (int i = 0; i < (int)(n); i++) {
    l = max(l, a[i] - i);
    if (p - 1 <= i) r = min(r, a[i] - i + (p - 1));
  }
  vector<int> ans;
  for (int i = l; i < r; i++) ans.push_back(i);
  cout << ((int)(ans).size()) << endl;
  for (auto x : ans) cout << x << ' ';
  return 0;
}
