#include <bits/stdc++.h>
using namespace std;
int counts[2000 + 2];
int cumul_counts[2000 + 2];
int main() {
  int n, p;
  cin >> n >> p;
  for (int i = 0; i <= 2000; i++) counts[i] = 0;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    counts[x]++;
  }
  cumul_counts[0] = counts[0];
  for (int i = 1; i <= 2000; i++)
    cumul_counts[i] = counts[i] + cumul_counts[i - 1];
  vector<int> ans;
  for (int x = 1; x <= 2000; x++) {
    long long total_perms = 1;
    for (int c = x; c <= x + n - 1; c++) {
      int curr = (c > 2000 ? cumul_counts[2000] : cumul_counts[c]) - (c - x);
      total_perms = (total_perms * curr) % p;
    }
    if (total_perms != 0) {
      ans.push_back(x);
    }
  }
  cout << ans.size() << endl;
  for (int x : ans) printf("%d ", x);
  cout << endl;
}
