#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
using ld = long double;
int ctoi(const char c) {
  if ('0' <= c && c <= '9') return (c - '0');
  return -1;
}
ll gcd(ll a, ll b) { return (b == 0 ? a : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
constexpr ll MOD = 1000000007;
constexpr ll INF = 1000000011;
constexpr ll MOD2 = 998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS = 10e-8;
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return 1;
  }
  return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return 1;
  }
  return 0;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto&& x : v) is >> x;
  return is;
}
template <typename T, typename U>
istream& operator>>(istream& is, pair<T, U>& p) {
  is >> p.first;
  is >> p.second;
  return is;
}
template <typename T, typename U>
ostream& operator>>(ostream& os, const pair<T, U>& p) {
  os << p.first << ' ' << p.second;
  return os;
}
template <class T>
ostream& operator<<(ostream& os, vector<T>& v) {
  for (auto i = begin(v); i != end(v); ++i) {
    if (i != begin(v)) os << ' ';
    os << *i;
  }
  return os;
}
ll A[100007];
vector<ll> V;
map<ll, ll> M;
int main() {
  ll N, P;
  cin >> N >> P;
  for (ll i = 0; i < (N); ++i) {
    cin >> A[i];
    M[A[i]]++;
  }
  sort(A, A + N);
  ll ok = A[0];
  for (ll i = 0; i < (N); ++i) {
    ok = max(A[i] - i, ok);
  }
  ll T = ok;
  ll ng = 1000000001;
  ok--;
  while (ng - ok > 1) {
    ll X = (ok + ng) / 2;
    ll R = 0;
    ll Y = X;
    bool Z = 0;
    for (auto p : M) {
      ll j = p.first;
      if (M[j] > 0) {
        if (X >= j) {
          R += M[j];
        } else {
          if (R < j - X) {
            Z = 1;
            break;
          }
          R += M[j] - (j - X);
          X = j;
        }
      }
      if (R >= P) {
        Z = 1;
        break;
      }
    }
    if (Z == 0) {
      ok = Y;
    } else {
      ng = Y;
    }
  }
  cout << ok - T + 1 << '\n';
  for (ll i = (T); i < (ok + 1); ++i) {
    cout << i;
    if (i != ok) {
      cout << " ";
    }
  }
  cout << '\n';
}
