#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
int a[N], p, n;
bool check(int x) {
  for (int i = 1; i <= n; i++) {
    int pos = i + x - 1;
    int ans = upper_bound(a + 1, a + n + 1, pos) - a - 1;
    if ((ans - i + 1) >= p) return 0;
  }
  return 1;
}
int main() {
  int m, k;
  cin >> n >> p;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  int now = a[1];
  int pos = a[1];
  for (int i = 1; i <= n; i++) {
    if (now >= a[i])
      now++;
    else
      pos += (a[i] - now), now += (a[i] - now + 1);
  }
  int mx = *max_element(a + 1, a + n + 1);
  int l = pos, r = mx;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (check(mid))
      l = mid + 1;
    else
      r = mid - 1;
  }
  cout << r - pos + 1 << '\n';
  for (int i = pos; i <= r; i++) cout << i << ' ';
}
