#include <bits/stdc++.h>
using namespace std;
template <class T>
void printvec(vector<T>& x, int a, int b) {
  for (int i = (a); i <= (b); i++) cout << x[i] << " ";
  cout << "\n";
}
const double PI = acos((double)-1);
const double EPSILON = 1e-7;
const int N = 2e6 + 1;
const int NN = 1e3 + 1;
const long long MOD = 1e9 + 7;
const long long oo = LLONG_MAX;
const int BASE = 10000;
const int di[4] = {-1, 0, 1, 0};
const int dj[4] = {0, 1, 0, -1};
void query() {
  int n, p;
  cin >> n >> p;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(1 + (a).begin(), (a).end());
  int minx = max(0, a[n] - n + 1);
  vector<int> small(2 * n);
  for (int i = minx; i <= minx + 2 * n - 2; i++) {
    small[i - minx] =
        upper_bound(1 + (a).begin(), (a).end(), i) - a.begin() - 1;
  }
  int maxa = n - 1;
  for (int i = 0; i < 2 * n; i++) {
    if (small[i] < p) {
      continue;
    }
    maxa = min(maxa, i - small[i] + p - 1);
  }
  int l = 0, r = n - 1;
  while (l < r) {
    int mid = (l + r) / 2;
    int check = 1;
    for (int i = 0; i < n; i++) {
      if (small[mid + i] - i <= 0) {
        check = 0;
        break;
      }
    }
    if (check) {
      r = mid;
    } else {
      l = mid + 1;
    }
  }
  cout << max(maxa - l + 1, 0) << "\n";
  for (int i = l; i <= maxa; i++) {
    cout << minx + i << " ";
  }
}
void solve() {
  int t = 1;
  while (t--) {
    query();
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << fixed << setprecision(10);
  solve();
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
  return 0;
}
