#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 50;
long long T, n, p, a[N];
vector<long long> ans;
signed main() {
  ios::sync_with_stdio(false);
  cin >> n >> p;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1, greater<long long>());
  for (long long x = max(1ll, a[1] - n + 1); x <= a[1]; x++) {
    long long now = 1, r = x + n - 1;
    for (long long i = 1; i <= n; i++) {
      now = (now * (min(r - a[i] + 1, n) - i + 1)) % p;
    }
    if (now) {
      ans.push_back(x);
    }
  }
  cout << ans.size() << endl;
  for (auto &x : ans) {
    cout << x << " ";
  }
}
