#include <bits/stdc++.h>
using namespace std;
const int maxn = 2050;
int a[maxn], ans[maxn];
int n, p;
void solve() {
  scanf("%d %d", &n, &p);
  int max_v = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    max_v = max(max_v, a[i]);
  }
  sort(a + 1, a + n + 1);
  int res = 0;
  for (int i = 1; i <= max_v; i++) {
    int now = i, sum = 0, flag = 1;
    for (int j = 1; j <= n; j++) {
      if (a[j] <= now) {
        sum++;
        if (sum == p) {
          flag = 0;
          break;
        }
      } else {
        int tmp = a[j] - now;
        sum -= tmp;
        now += tmp;
        if (sum < 0) {
          flag = 0;
          break;
        }
        sum++;
      }
    }
    if (flag) {
      ans[++res] = i;
    }
  }
  printf("%d\n", res);
  for (int i = 1; i <= res; i++) printf("%d ", ans[i]);
  printf("\n");
}
int main() {
  solve();
  return 0;
}
