#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve() {
  int n, p;
  cin >> n >> p;
  vector<int> a(n);
  for (int &i : a) cin >> i;
  sort(a.begin(), a.end());
  vector<int> b(n);
  int mn = -1000000007;
  for (int i = 0; i < n; i++) {
    b[i] = a[i] - i;
    mn = max(mn, b[i]);
  }
  ll L = mn, R = 1000000007;
  while (L != R) {
    ll M = (L + R) / 2;
    int ans = 0;
    vector<int> c(n);
    int i = 0, previ = -1, tans = 1;
    for (int j = 0; j < n; j++) {
      if (1 || a[j] > M + i) i = max(0LL, a[j] - M), c[j] = i;
    }
    for (int i = 0; i < n; i++) {
      ans = max(ans, i - c[i] + 1);
    }
    if (ans >= p)
      R = M;
    else
      L = M + 1;
  }
  int mx = L;
  cout << mx - mn << '\n';
  for (int i = mn; i < mx; i++) {
    cout << i << ' ';
  }
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int owo = 1;
  while (owo--) solve();
}
