#include <bits/stdc++.h>
using namespace std;
const long long MAX = 2e5 + 5;
long long n, p;
long long a[MAX];
long long maxi = 0;
bool check(long long x) {
  long long ans = 1;
  long long prex = x;
  if (x > maxi) return 0;
  long long ile = 0;
  long long wsk = 1;
  for (long long i = 1; i <= n; i++) {
    if (a[i] <= x) {
      ile++;
    } else {
      while (a[i] > x) {
        if (!ile) return 0;
        ans = (ans * ile) % p;
        ile--;
        x++;
      }
      ile++;
    }
    if (i == n) {
      while (ile) {
        ans = (ans * ile) % p;
        ile--;
      }
    }
  }
  return ans % p != 0;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> p;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    maxi = max(maxi, a[i]);
  }
  sort(a + 1, a + n + 1);
  vector<long long> ans;
  ans.clear();
  for (long long i = maxi - n; i <= maxi; i++) {
    if (check(i)) {
      ans.push_back(i);
    }
  }
  cout << (long long)ans.size() << "\n";
  for (auto it : ans) cout << it << " ";
  return 0;
}
