#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, p;
  cin >> n >> p;
  vector<int> a(n);
  for (auto &i : a) cin >> i;
  int m = *max_element((a).begin(), (a).end());
  vector<int> freq(m + n + 10);
  for (int i = 0; i < n; i++) {
    freq[a[i]]++;
  }
  for (int i = 1; i < m + n + 10; i++) {
    freq[i] += freq[i - 1];
  }
  vector<int> ans;
  for (int x = max(1, m - n + 1); x < m; x++) {
    int i = 0;
    while (i < n) {
      int vals = (freq[x + i] - i);
      if (vals % p == 0) {
        break;
      }
      i++;
    }
    if (i == n) ans.push_back(x);
  }
  cout << ans.size() << endl;
  for (auto &x : ans) {
    cout << x << " ";
  }
  return 0;
}
