#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000 + 5;
int n, pr, ans;
int a[maxn];
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n >> pr;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  vector<int> ans_x;
  for (int i = a[0]; i < a[n - 1]; i++) {
    int idx = 0, res = 1, p;
    bool ok = true;
    for (int j = 0; j < n; j++) {
      p = idx;
      while (idx < n) {
        if (i + j >= a[idx])
          idx++;
        else
          break;
      }
      if (idx - j < 0) ok = false;
      res *= idx - j;
      res %= pr;
    }
    if (ok && res != 0) {
      ans_x.push_back(i);
      ans++;
    }
  }
  cout << ans << '\n';
  for (auto &x : ans_x) cout << x << ' ';
}
