#include <bits/stdc++.h>
using namespace std;
void fs(long long int &number) {
  bool negative = false;
  register int c;
  number = 0;
  c = getchar();
  if (c == '-') {
    negative = true;
    c = getchar();
  }
  for (; (c > 47 && c < 58); c = getchar()) number = number * 10 + c - 48;
  if (negative) number *= -1;
}
long long int modOfLargeNo(string s, long long int n) {
  long long int res = 0;
  for (long long int i = 0; i < s.length(); i++) {
    res = (res * 10 + (long long int)s[i] - '0') % n;
  }
  return res;
}
long long int numOfDigits(long long int n) { return floor(log10(n)) + 1; }
bool getParity(unsigned int n) {
  bool parity = 0;
  while (n) {
    parity = !parity;
    n = n & (n - 1);
  }
  return parity;
}
long long int findS(long long int s) { return (sqrt(8 * s) + 1) / 2; }
bool isprime(long long int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (long long int i = 5; i * i <= n; i = i + 6) {
    if (n % i == 0 || n % (i + 2) == 0) {
      return false;
    }
  }
  return true;
}
int binSearch(long long int arr[], long long int l, long long int r,
              long long int x) {
  while (l <= r) {
    long long int m = l + (r - l) / 2;
    if (arr[m] == x) {
      return m;
    }
    if (arr[m] < x) {
      l = m + 1;
    } else {
      r = m - 1;
    }
  }
  return -1;
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return (a * b) / gcd(a, b);
}
long long int countDivisors(long long int n) {
  long long int cnt = 0;
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i)
        cnt++;
      else
        cnt = cnt + 2;
    }
  }
  return cnt;
}
void dfs(vector<long long int> v[], bool visited[],
         long long int current_node) {
  visited[current_node] = true;
  for (long long int nxt_node : v[current_node]) {
    if (visited[nxt_node] == false) {
      dfs(v, visited, nxt_node);
    }
  }
  return;
}
long long int nCr(long long int n, long long int r) {
  if (r == 0) return 1;
  return (n * nCr(n - 1, r - 1)) / r;
}
bool checkisTree(long long int degree[], long long int n) {
  long long int deg_sum = 0;
  for (long long int i = 0; i < n; i++) deg_sum += degree[i];
  return (2 * (n - 1) == deg_sum);
}
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, p;
  cin >> n >> p;
  vector<int> arr(n);
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  sort(arr.begin(), arr.end());
  int min_value = 0;
  for (int i = 0; i < n; i++) {
    min_value = max(min_value, arr[i] - i);
  }
  int max_value = arr[n - 1];
  int low = min_value;
  int high = max_value;
  int mid;
  int ans = min_value - 1;
  while (high >= low) {
    mid = (low + high) / 2;
    long long start = 1;
    int flag = 0, mm = mid;
    for (int j = 0; j < n; j++) {
      int temp = upper_bound(arr.begin(), arr.end(), mm) - arr.begin();
      mm++;
      start = (start * (temp - j)) % p;
      if (start == 0) {
        flag = 1;
        break;
      }
    }
    if (flag)
      high = mid - 1;
    else {
      low = mid + 1;
      ans = mid;
    }
  }
  cout << (ans - min_value + 1) << endl;
  for (int i = min_value; i <= ans; i++) {
    cout << i << " ";
  }
  cout << endl;
  return 0;
}
