#include <bits/stdc++.h>
using namespace std;
int is_good(int x, vector<int>& a, int n, int p) {
  vector<int> cnt(2001, 0);
  for (auto y : a) {
    cnt[max(y - x, 0)]++;
  }
  for (int i = 1; i < n; i++) {
    cnt[i] += cnt[i - 1] - 1;
  }
  bool poss = true;
  for (int i = 0; i < n; i++) {
    if (cnt[i] % p == 0) {
      poss = false;
    }
  }
  return poss;
}
int main() {
  int p, n;
  vector<int> a, answ;
  cin >> n >> p;
  a.assign(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  for (int i = 1; i <= 2000; i++) {
    if (is_good(i, a, n, p)) {
      answ.push_back(i);
    }
  }
  cout << answ.size() << '\n';
  for (auto y : answ) {
    cout << y << " ";
  }
  cout << '\n';
  return 0;
}
