#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using cd = complex<double>;
int cc[(ll)(5e5 + 7)];
int main() {
  int n, p;
  cin >> n >> p;
  int ar[n];
  for (int i = 0; i < n; i++) {
    cin >> ar[i];
    cc[ar[i]]++;
  }
  int c = 0, co = 0, ans = 0;
  vector<int> ve;
  for (int i = 1; i <= 2000; i++) {
    c = i;
    int cx = co, fl = 1;
    for (int j = 1; j <= n; j++) {
      cx += cc[c];
      if (cx % p == 0) {
        fl = 0;
        break;
      }
      cx--;
      c++;
    }
    co += cc[i];
    if (fl) {
      ve.push_back(i);
    }
  }
  cout << ve.size() << "\n";
  for (int i = 0; i < ve.size(); i++) {
    cout << ve[i] << " ";
  }
  cout << "\n";
}
