#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
long long n, p;
long long a[100010];
signed main() {
  cin >> n >> p;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    a[i];
  }
  sort(a, a + n);
  vector<long long> vec;
  for (long long k = 0; k <= 2100; k++) {
    long long j = 0;
    long long ans = 1;
    for (long long i = 0; i < n; i++) {
      while (j < n && a[j] <= k + i) {
        j++;
      }
      if (j == i) {
        ans = 0;
        break;
      }
      ans *= (j - i);
      ans %= p;
      if (ans == 0) break;
    }
    if (ans != 0) {
      vec.push_back(k);
    }
  }
  cout << vec.size() << endl;
  for (long long i = 0; i < vec.size(); i++) {
    cout << vec[i];
    if (i < vec.size() - 1) {
      cout << " ";
    }
  }
  cout << endl;
  return 0;
}
