#include <bits/stdc++.h>
using namespace std;
const long long ooo = 1e14;
const long long oo = 2e9;
const double PI = acos(-1);
const long long M = 1e9 + 7;
const int N = 1000010;
long long a[100010];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, p;
  cin >> n >> p;
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a, a + n);
  long long l = 0, h = oo;
  for (int i = 0; i < n; ++i) {
    l = max(l, a[i] - i);
    if (i + 1 >= p) h = min(h, a[i] - i + p - 1);
  }
  cout << max(h - l, 0ll) << "\n";
  for (int i = l; i < h; ++i) cout << i << ' ';
  cout << "\n";
}
