#include <bits/stdc++.h>
using namespace std;
const int MAX = 2000 + 10;
int arr[MAX], appear[MAX];
int n, p;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> p;
  for (int i = 0; i < n; ++i) cin >> arr[i];
  vector<int> ans;
  for (int i = 1; i < 2000; ++i) {
    for (int j = 0; j < 2000; ++j) appear[j] = 0;
    for (int j = 0; j < n; ++j) {
      int x = max(0, arr[j] - i);
      appear[x]++;
    }
    int now = 1, cnt = 1;
    for (int j = 0; j < n; ++j) {
      now--;
      now += appear[j];
      cnt = (cnt * now) % p;
    }
    if (cnt != 0) ans.push_back(i);
  }
  cout << ans.size() << "\n";
  for (auto &i : ans) cout << i << " ";
  cout << "\n";
  return 0;
}
