#include <bits/stdc++.h>
using namespace std;
const int maxn = 111111;
long long n, p, l, r;
vector<long long> a(maxn);
bool inv(long long x) {
  for (int i = 0; i < n; i++) {
    long long pre = upper_bound(a.begin(), a.end(), x + i) - a.begin() - i;
    if (pre == 0) return true;
  }
  return false;
}
bool div(long long x) {
  for (int i = 0; i < n; i++) {
    long long pre = upper_bound(a.begin(), a.end(), x + i) - a.begin() - i;
    if (pre % p == 0 && pre != 0) return true;
  }
  return false;
}
int main() {
  cin >> n >> p;
  for (int i = 0; i < n; i++) cin >> a[i];
  a.resize(n);
  sort(a.begin(), a.end());
  long long lo = 0, hi = 2000000000;
  while (lo < hi) {
    long long m = (lo + hi) >> 1;
    if (inv(m))
      lo = m + 1;
    else
      hi = m;
  }
  l = lo;
  lo--;
  hi = 2000000000;
  while (lo + 1 < hi) {
    long long m = (lo + hi) >> 1;
    if (div(m))
      hi = m;
    else
      lo = m;
  }
  r = lo;
  cout << max(r - l + 1, (long long)0) << endl;
  for (int i = l; i <= r; i++) cout << i << " ";
  puts("");
  return 0;
}
