#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, p;
  cin >> n >> p;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n, greater<int>());
  vector<int> ans;
  for (int i = a[n - 1]; i < a[0]; i++) {
    int g = i + n - 1;
    bool flag = true;
    for (int j = 0; j < n; j++) {
      int choices = min(g - i + 1 - j, g - a[j] - j + 1);
      if (choices <= 0 || choices % p == 0) {
        flag = false;
        break;
      }
    }
    if (flag) ans.push_back(i);
  }
  cout << ans.size() << '\n';
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  return 0;
}
