#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int sINF = 0xcfcfcfcf;
const int M = 1e5 + 5;
const int N = 1e3 + 5;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = 10 * x + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int a[M];
unordered_map<int, int> mp;
int sum[M];
int mx;
vector<int> ans;
bool isv[M];
int m;
int main() {
  int n, p;
  n = read(), p = read();
  for (int i = 0; i < n; i++) {
    a[i] = read();
  }
  sort(a, a + n);
  int l, r;
  l = 0, r = INF;
  for (int i = 0; i < n; i++) {
    l = max(l, a[i] - i);
  }
  for (int i = 0; i < n && (i + p - 1) < n; i++) {
    r = min(r, a[i + p - 1] - i - 1);
  }
  if (l <= r) {
    cout << r - l + 1 << endl;
    for (int i = l; i <= r; i++) {
      cout << i << " ";
    }
  } else
    cout << 0 << endl;
}
