#include <bits/stdc++.h>
using namespace std;
long long t, n, m, nn, mm, h, r, l, i, j, ii, x[1000001], y[1000001], z, g, a,
    b, c, d, k, q, mod = 1e9 + 7;
vector<long long> v, v1, v2, vv;
vector<long long> vvv;
queue<pair<long long, long long> > qq;
pair<long long, long long> p;
map<long long, long long> mp, mpp, mppp, vis;
set<long long> se;
multiset<long long> sw;
set<long long>::iterator it;
string s;
char cc[1000001];
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> k;
  for (i = 0; i < n; i++) cin >> x[i];
  sort(x, x + n);
  for (i = x[0]; i <= x[n - 1]; i++) {
    z = 1;
    for (j = 0; j < n; j++) {
      a = upper_bound(x, x + n, i + j) - x;
      z *= (a - j);
      z %= k;
    }
    if (z % k != 0) v.push_back(i);
  }
  cout << v.size() << endl;
  for (i = 0; i < v.size(); i++) cout << v[i] << ' ';
  return 0;
}
