#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
const int base = 1e9;
const int mod = 1e9 + 7;
int n, p;
int a[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> p;
  int mi = base, l = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + n + 1);
  int c = 1;
  for (int i = n; i >= 1; i--) {
    if (a[i] == a[i + 1])
      c++;
    else
      c = 1;
    if (i + c - 1 >= p) mi = min(mi, a[i] - (i + c - p - 1));
    l = max(l, a[i] - i + 1);
  }
  cout << max(0, mi - l) << '\n';
  for (int i = l; i < mi; i++) cout << i << " ";
  return 0;
}
