#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, p;
  cin >> n >> p;
  vector<int> a(n);
  for (auto &x : a) cin >> x;
  sort(a.begin(), a.end());
  vector<int> ans;
  for (int i = a[0]; i < a[n - 1]; i++) {
    long long int perm = 1;
    for (int j = 0; j < n; j++) {
      perm = (perm * min(j + 1, max(0, (i + j) - a[j] + 1))) % p;
      if (perm == 0) break;
    }
    if (perm != 0) ans.push_back(i);
  }
  cout << ans.size() << endl;
  for (auto &x : ans) cout << x << " ";
  cout << endl;
  return 0;
}
