#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, p, num, mi = 1000000, ma = 0, ans = 1;
  cin >> n >> p;
  vector<long long> v, res;
  for (long long i = 0; i < n; i++) {
    cin >> num;
    v.push_back(num);
    mi = min(mi, num);
    ma = max(ma, num);
  }
  sort(v.begin(), v.end());
  for (long long i = mi; i <= ma; i++) {
    ans = 1;
    for (long long j = 0; j < n; j++) {
      auto it = upper_bound(v.begin(), v.end(), i + j);
      it--;
      ans *= (distance(v.begin(), it) + 1 - j);
      ans = ans % p;
    }
    if (ans) {
      if (ans % p != 0) res.push_back(i);
    }
  }
  cout << res.size() << endl;
  for (long long i = 0; i < res.size(); i++) cout << res[i] << " ";
}
