#include <bits/stdc++.h>
using namespace std;
const int maxi = 1e6 + 10;
int a[maxi];
string s;
int t;
vector<int> v[maxi];
int n;
long long p;
int check(int x) {
  long long val = 1;
  int id = 1;
  for (int i = 1; i <= n; i++) {
    int l = i;
    while (id <= n && a[id] <= x + l - 1) id++;
    id--;
    if (id - l + 1 >= p) return 0;
  }
  return 1;
}
int main() {
  cin >> n >> p;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  int mx = 0;
  for (int i = 1; i <= n; i++) mx = max(mx, a[i] - i + 1);
  int l = mx - 1;
  int r = l + 100010;
  while (l < r - 1) {
    int mid = (l + r) / 2;
    if (check(mid))
      l = mid;
    else
      r = mid;
  }
  int val = max(0, l - (mx - 1));
  printf("%d\n", val);
  assert(val <= 1e5);
  for (int i = mx; i < mx + val; i++) printf("%d ", i);
  printf("\n");
  return 0;
}
