#include <bits/stdc++.h>
using namespace std;
long long a[5000 + 1], cnt[5000 + 1];
long long pre_cnt[5000 + 1];
vector<long long> ans_list;
int main() {
  long long n, p, m = 0;
  cin >> n >> p;
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    m = max(m, a[i]);
  }
  for (long long i = 1; i <= n; i++) cnt[a[i]]++;
  for (long long i = 1; i <= m; i++) pre_cnt[i] = pre_cnt[i - 1] + cnt[i];
  for (long long x = m - n + 1; x < m; x++) {
    if (x <= 0) continue;
    long long v = pre_cnt[x - 1], ans = 1;
    for (long long i = x; i <= x + n - 1; i++) {
      v += cnt[i];
      ans *= v;
      ans %= p;
      v--;
    }
    if (ans % p != 0) ans_list.push_back(x);
  }
  cout << ans_list.size() << "\n";
  for (int i = 0; i < ans_list.size(); i++) {
    printf("%lld ", ans_list[i]);
  }
  return 0;
}
