#include <bits/stdc++.h>
using namespace std;
const int N = 2e3;
const int INF = 1e9;
int n, p;
int ar[N + 2];
map<int, int> freq;
int binser(int x) {
  int ret = n + 1;
  for (int l = 1, r = n; l <= r;) {
    int m = (l + r) / 2;
    if (ar[m] >= x) {
      ret = m;
      r = m - 1;
    } else
      l = m + 1;
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  clock_t ck;
  ck = clock();
  cin >> n >> p;
  int maxi = 0;
  int mini = INF;
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    cin >> ar[i];
    freq[ar[i]]++;
    sum += ar[i];
    mini = min(mini, ar[i]);
    maxi = max(maxi, ar[i]);
  }
  sort(ar + 1, ar + n + 1);
  vector<int> res;
  for (int i = maxi - n + 1; i < maxi; i++) {
    int v = binser(i);
    v--;
    long long ans = 1;
    for (int j = 0; j < n; j++) {
      v += freq[i + j];
      ans *= v;
      ans %= p;
      v--;
    }
    if (ans % p != 0) res.push_back(i);
  }
  cout << res.size() << '\n';
  for (int i : res) {
    cout << i << ' ';
  }
  cout << '\n';
  ck = clock() - ck;
  cerr << "It took " << 1.0 * ck / CLOCKS_PER_SEC << " sec\n";
  return 0;
}
