#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;
int n, p;
int arr[100100];
int solve(long long x) {
  for (int i = 0; i < n; i++) {
    int pos = upper_bound(arr, arr + n, x) - arr;
    if (pos - i >= p) return 1;
    if (arr[i] > x) break;
    x++;
  }
  return 0;
}
long long binary_search(long long x, long long y) {
  long long lo = x - 1;
  long long hi = y + 1;
  while (lo + 1 < hi) {
    long long mid = (lo + hi) / 2;
    if (solve(mid))
      hi = mid;
    else
      lo = mid;
  }
  return hi;
}
int main() {
  int start;
  int ed;
  scanf("%d %d", &n, &p);
  for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
  sort(arr, arr + n);
  start = 0;
  for (int i = 0; i < n; i++) start = max(start, arr[i] - i);
  ed = (int)binary_search(start, 1e9);
  printf("%d\n", ed - start);
  for (int i = start; i < ed; i++) printf("%d ", i);
  printf("\n");
  return 0;
}
