#include <bits/stdc++.h>
using namespace std;
long long int N, P;
vector<long long int> vec;
bool possible(long long int x) {
  for (long long int i = 0; i < N; i++) {
    if (x + i < vec[i]) return false;
  }
  return true;
}
long long int bin(long long int x) {
  long long int low = 0, high = N - 1;
  long long int ans = -1, mid = 0;
  while (low <= high) {
    mid = (low + high) / 2;
    if (vec[mid] <= x) {
      ans = mid + 1;
      low = mid + 1;
    } else
      high = mid - 1;
  }
  return ans;
}
long long int small() {
  long long int low = 0, high = 1e10;
  long long int ans = 0, mid;
  while (low <= high) {
    mid = (low + high) / 2;
    if (possible(mid)) {
      ans = mid;
      high = mid - 1;
    } else
      low = mid + 1;
  }
  return ans;
}
long long int prod(long long int x) {
  long long int pro = 1;
  for (long long int i = 0; i < N; i++) {
    long long int t = bin(x + i) - i;
    pro *= t;
    pro %= P;
  }
  return pro % P;
}
long long int big(long long int low) {
  long long int high = 1e10;
  long long int ans = low, mid;
  while (low <= high) {
    mid = (low + high) / 2;
    if (possible(mid) && prod(mid) != 0) {
      ans = mid;
      low = mid + 1;
    } else
      high = mid - 1;
  }
  return ans;
}
void solve() {
  cin >> N >> P;
  vec.resize(N);
  for (int i = 0; i < (N); i++) cin >> vec[i];
  ;
  sort(vec.begin(), vec.end());
  long long int low = small();
  if (prod(low) == 0) {
    cout << "0\n" << endl;
    return;
  }
  long long int high = big(low);
  cout << high - low + 1 << endl;
  for (long long int i = low; i <= high; i++) cout << i << " ";
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T;
  T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
