#include <bits/stdc++.h>
using namespace std;
int n, x, mx, mod, ans, a[100001], b[200001], c[100001], d[100001];
inline long long read() {
  long long sum = 0, x = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') x = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    sum = sum * 10 + ch - '0';
    ch = getchar();
  }
  return sum * x;
}
inline void write(long long x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
  return;
}
int main() {
  n = read();
  mod = read();
  for (register int i = 1; i <= n; ++i) {
    a[i] = read();
    mx = max(mx, a[i]);
  }
  x = mx - n;
  for (register int i = 1; i <= n; ++i) ++b[max(0, a[i] - x)];
  for (register int i = 1; i <= (int)2e5; ++i) b[i] += b[i - 1];
  for (register int i = 0; i < n; ++i) ++d[((i + x - b[i]) % mod + mod) % mod];
  for (register int i = 0; i <= n; ++i) {
    if (!d[((i + x) % mod + mod) % mod]) c[++ans] = i + x;
    --d[((i + x - b[i]) % mod + mod) % mod];
    ++d[((i + n + x - b[i + n]) % mod + mod) % mod];
  }
  write(ans);
  putchar('\n');
  for (register int i = 1; i <= ans; ++i) {
    write(c[i]);
    putchar(' ');
  }
  return 0;
}
