#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, p, mn = 2000000, mx = -1, t = 0, ans1 = 0, i, j;
  vector<long long> ans;
  cin >> n >> p;
  long long ara[n + 1];
  for (i = 1; i <= n; i++) {
    cin >> ara[i];
    mn = min(mn, ara[i]);
    mx = max(mx, ara[i]);
  }
  sort(ara + 1, ara + n + 1);
  for (i = mn; i <= mx; i++) {
    int ind = 1;
    vector<long long> v;
    t = 1;
    long long h = 1;
    for (j = i; j <= i + n - 1; j++) {
      while (ara[ind] <= j) {
        ind++;
      }
      long long k = ind - 1;
      if (k < h) {
        t = 0;
        break;
      }
      v.push_back(k);
      h++;
    }
    if (t == 0) {
      continue;
    }
    long long x = 1;
    for (j = 0; j < v.size(); j++) {
      x = ((x % p) * ((v[j] - j) % p)) % p;
    }
    if (x != 0) {
      ans1++;
      ans.push_back(i);
    }
  }
  cout << ans1 << endl;
  for (i = 0; i < ans.size(); i++) {
    printf("%lld ", ans[i]);
  }
  cout << endl;
}
