#include <bits/stdc++.h>
using namespace std;
const long double pi = acos(-1);
const long long inf = 1e9 + 9;
const double eps = 1e-9;
const long long mod = 1e9 + 7;
const int N = 100100, MX = inf;
int a[N];
int n, p;
bool ok1(int x) {
  for (int i = 0; i < n; i++) {
    if (a[i] > x) return 0;
    x++;
  }
  return 1;
}
bool ok2(int x) {
  int cnt = 0;
  int j = 0;
  while (1) {
    while (j < n && a[j] <= x) {
      j++;
      cnt++;
    }
    if (cnt >= p) return 1;
    if (j == n) break;
    cnt--;
    x++;
  }
  return 0;
}
int main() {
  scanf("%d%d", &n, &p);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  int lo1 = 1, hi1 = MX;
  while (hi1 > lo1) {
    int mid1 = (lo1 + hi1) / 2;
    if (ok1(mid1))
      hi1 = mid1;
    else
      lo1 = mid1 + 1;
  }
  int lx = lo1;
  int lo2 = lx, hi2 = MX;
  while (hi2 > lo2) {
    int mid2 = (lo2 + hi2) / 2;
    if (ok2(mid2))
      hi2 = mid2;
    else
      lo2 = mid2 + 1;
  }
  int rx = lo2 - 1;
  printf("%d\n", rx - lx + 1);
  for (int i = lx; i <= rx; i++) printf("%d ", i);
}
