#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1, -1, -1, 0, 1, -1, 0, 1};
int kx8[] = {1, 1, 2, 2, -1, -1, -2, -2};
int ky8[] = {2, -2, 1, -1, 2, -2, 1, -1};
long long bigmod(long long a, long long b, long long c) {
  if (b == 0) return 1 % c;
  long long x = bigmod(a, b / 2, c);
  x = (x * x) % c;
  if (b % 2 == 1) x = (x * a) % c;
  return x;
}
long long mod_inverse(long long a, long long mod) {
  return bigmod(a, mod - 2, mod);
}
long long a[100005 * 2], sum[100005 * 2], frq[100005 * 2];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, p;
  long long N = 2000;
  cin >> n >> p;
  for (int i = 0; i < (n); i++) {
    cin >> a[i];
    frq[a[i]]++;
  }
  for (int i = 1; i <= 100005; i++) {
    sum[i] = sum[i - 1] + frq[i];
  }
  vector<int> v;
  for (long long i = 1; i <= N; i++) {
    long long mul = 1;
    for (int j = 1; j <= n; j++) {
      long long to = i + j - 1;
      long long now = sum[to] - (j - 1);
      if (now <= 0) {
        mul = 0;
        break;
      }
      mul *= now;
      mul %= p;
      if (mul % p == 0) break;
    }
    if (mul) v.push_back(i);
  }
  cout << v.size() << endl;
  for (auto x : v) cout << x << " ";
  cout << endl;
  return 0;
}
