#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
int n, p, a[N];
map<int, int> seg;
vector<int> ans;
bool check(int x) {
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    while (cnt < n && a[cnt + 1] <= x + i - 1) cnt++;
    if (cnt < i) return false;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> p;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + 1 + n);
  int l = 1, r = a[n];
  while (l < r) {
    int mid = (l + r) >> 1;
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  seg[l]--;
  seg[a[n]]++;
  for (int i = 1; i <= n; i++) {
    if (n - i + 1 < p) break;
    int pos = i + p - 1;
    if (pos != n && a[pos] == a[pos + 1]) continue;
    seg[a[pos] - i + 1]++;
    if (pos == n)
      continue;
    else {
      seg[a[pos + 1] - i + 1]--;
    }
  }
  int cur = 0, lst = -1;
  for (auto p : seg) {
    if (cur < 0) {
      for (int i = lst; i < p.first; i++) ans.push_back(i);
    }
    cur += p.second;
    lst = p.first;
  }
  cout << (int)ans.size() << "\n";
  for (int x : ans) cout << x << " ";
}
