#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 5, MAX = 1e5 + 5;
int n, p;
int a[N], pref[MAX];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> p;
  memset(pref, 0, sizeof pref);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    pref[a[i]]++;
  }
  for (int i = 1; i <= 100000; i++) pref[i] += pref[i - 1];
  vector<int> ans;
  for (int x = 1; x <= 100000; x++) {
    bool ok = 1;
    for (int i = 0; i < n && ok; i++) {
      int nw = x + i;
      if (pref[nw] - i <= 0) ok = 0;
      if ((pref[nw] - i) % p == 0) ok = 0;
    }
    if (ok) ans.push_back(x);
  }
  cout << ans.size() << '\n';
  for (auto& it : ans) cout << it << ' ';
  cout << '\n';
  return 0;
}
