#include <bits/stdc++.h>
using namespace std;
const int maxm = 2e3 + 23;
const int maxn = 2e5 + 35;
int n, p, a[maxn];
bool check(int first) {
  int ans = 1;
  for (int i = n; i > 0; --i) {
    int c = max(0, a[i] - first) + 1;
    int num = n - c + 1 - (n - i);
    if (num <= 0) return false;
    ans = ans * num % p;
  }
  return ans;
}
int main() {
  cin >> n >> p;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  sort(a + 1, a + n + 1);
  vector<int> ans;
  for (int i = 1; i <= 2000; ++i) {
    if (check(i)) ans.push_back(i);
  }
  cout << (int)(ans).size() << '\n';
  for (int i = 0; i < (int)(ans).size(); ++i) cout << ans[i] << " ";
  return 0;
}
