#include <bits/stdc++.h>
using namespace std;
inline int rd(int f = 1, int x = 0, char ch = ' ') {
  while (!isdigit(ch = getchar()))
    if (ch == '-') f = -1;
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return f * x;
}
const int N = 1e5 + 5;
int n, p, a[N], mn, mx;
bool chk(int x) {
  long long ans = 1;
  for (int i = 1; i <= n; ++i)
    if (((ans *= n - max(a[i] - x, 0) - (i - 1)) %= p) == 0) return false;
  return true;
}
int main() {
  n = rd(), p = rd(), mn = 1;
  for (int i = 1; i <= n; ++i) a[i] = rd();
  sort(a + 1, a + n + 1), reverse(a + 1, a + n + 1);
  for (int i = 1; i <= n; ++i) mn = max(mn, i - n + a[i]);
  mx = mn - 1;
  for (int l = mn, r = a[1], x; l <= r;)
    x = (l + r) >> 1, chk(x) ? (l = x + 1, mx = x) : (r = x - 1);
  printf("%d\n", mx - mn + 1);
  for (int i = mn; i <= mx; ++i) printf("%d ", i);
  puts("");
  return 0;
}
