#include <bits/stdc++.h>
char *fs, *ft, buf[1 << 20];
inline int read() {
  int x = 0, f = 1;
  char ch =
      (fs == ft && (ft = (fs = buf) + fread(buf, 1, 1 << 20, stdin), fs == ft))
          ? 0
          : *fs++;
  ;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = (fs == ft &&
          (ft = (fs = buf) + fread(buf, 1, 1 << 20, stdin), fs == ft))
             ? 0
             : *fs++;
    ;
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = (fs == ft &&
          (ft = (fs = buf) + fread(buf, 1, 1 << 20, stdin), fs == ft))
             ? 0
             : *fs++;
    ;
  }
  return x * f;
}
using namespace std;
int a[2009], b[2009];
int main() {
  int n, p;
  cin >> n >> p;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + 1 + n);
  int answer = 0;
  for (int i = a[1]; i <= a[n]; i++) {
    int bo = 0;
    int now = 1;
    for (int j = 1; j <= n; j++) {
      int gg = i + j - 1;
      while (gg >= a[now + 1] && now < n) {
        now++;
      }
      if (now - j + 1 >= 1) {
        if ((now - j + 1) % p == 0) {
          bo = 1;
          break;
        }
      } else {
        bo = 1;
        break;
      }
    }
    if (bo == 0) {
      answer++;
      b[answer] = i;
    }
  }
  cout << answer << endl;
  for (int i = 1; i <= answer; i++) cout << b[i] << ' ';
  cout << endl;
  return 0;
}
