#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, p;
  scanf("%d %d", &n, &p);
  vector<int> v(n + 1);
  vector<int> sumas(2 * n + 1);
  int m = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &v[i]);
    m = max(m, v[i]);
  }
  for (int i = 1; i <= n; i++) sumas[max(0, v[i] - m + n)]++;
  for (int i = 1; i <= 2 * n; i++) sumas[i] += sumas[i - 1];
  int inf, sup;
  inf = 1;
  for (int i = 1; i <= n; i++) {
    while (sumas[inf + i - 1] < i) inf++;
  }
  inf += (m - n);
  sup = n;
  for (int i = 1; i <= n; i++) {
    while (sup) {
      if (sumas[sup + i - 1] - (i - 1) < p) break;
      sup--;
    }
  }
  sup += (m - n);
  if (inf > sup) {
    printf("0\n\n");
    return 0;
  }
  printf("%d\n", sup - inf + 1);
  for (int i = inf; i <= sup; i++) printf("%d ", i);
  printf("\n");
  return 0;
}
