#include <bits/stdc++.h>
using namespace std;
int n, p, a[100010];
int judge(int x) {
  int now = 1, i;
  for (i = 1; i <= n; i++) {
    while (now <= n && a[now] <= x) now++;
    if ((now - i) % p == 0) return 1;
    x++;
  }
  return 0;
}
int main() {
  int i, maxi, l, r, mid;
  cin >> n >> p;
  for (i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + 1 + n);
  maxi = -1;
  for (i = 1; i <= n; i++) maxi = max(maxi, a[i] - i + 1);
  l = maxi - 1, r = 1000000000;
  while (l + 1 < r) {
    mid = (l + r) / 2;
    if (judge(mid))
      r = mid;
    else
      l = mid;
  }
  cout << l - maxi + 1 << endl;
  for (i = maxi; i <= l; i++) cout << i << " ";
  cout << endl;
  return 0;
}
