#include <bits/stdc++.h>
constexpr int MOD = 1000000007;
constexpr int NUM_BASES = 3;
constexpr int BASES[] = {3, 7, 109};
using namespace std;
using ll = long long;
int n, m;
int mod_pow(int b, int e) {
  if (e == 0) return 1;
  ll x = mod_pow(b, e >> 1);
  x = (x * x) % MOD;
  if (e & 1) x = (x * b) % MOD;
  return (int)x;
}
vector<pair<int, vector<int>>> pre_hash(vector<int> &sparse) {
  vector<pair<int, vector<int>>> ans;
  int last = 0;
  vector<int> h(NUM_BASES, 0);
  for (int idx : sparse) {
    for (int i = 0; i < NUM_BASES; ++i) {
      h[i] = (1LL * h[i] * mod_pow(BASES[i], idx - last) + 1) % MOD;
    }
    ans.push_back({idx, h});
    last = idx;
  }
  return ans;
}
vector<int> eval_hash(const vector<pair<int, vector<int>>> &h, int idx) {
  if (h[0].first > idx) return vector<int>(NUM_BASES, 0);
  int lo = 0, hi = (int)h.size();
  while (lo + 1 < hi) {
    int mid = (lo + hi) / 2;
    if (h[mid].first <= idx) {
      lo = mid;
    } else {
      hi = mid;
    }
  }
  vector<int> res(h[lo].second);
  for (int i = 0; i < res.size(); ++i) {
    res[i] = (1LL * res[i] * mod_pow(BASES[i], idx - h[lo].first)) % MOD;
  }
  return res;
}
vector<int> eval_hash(const vector<pair<int, vector<int>>> &h, int l, int r) {
  vector<int> right_hash = eval_hash(h, r);
  vector<int> left_hash =
      l == 0 ? vector<int>(NUM_BASES, 0) : eval_hash(h, l - 1);
  vector<int> ans;
  for (int i = 0; i < left_hash.size(); ++i) {
    left_hash[i] = (1LL * left_hash[i] * mod_pow(BASES[i], r - l + 1)) % MOD;
    ans.push_back((right_hash[i] - left_hash[i] + MOD) % MOD);
  }
  return ans;
}
int main() {
  scanf(" %d %d", &n, &m);
  vector<int> bag;
  for (int i = 0; i < n; ++i) {
    int x;
    scanf(" %d", &x);
    bag.push_back(x);
  }
  sort(bag.begin(), bag.end());
  vector<int> flipped;
  for (int x : bag) {
    flipped.push_back(m - 1 - x);
    flipped.push_back(m + m - 1 - x);
  }
  sort(flipped.begin(), flipped.end());
  vector<int> checks;
  for (int x : flipped) {
    if (x - bag[0] >= 0 && x - bag[0] < m) checks.push_back(x - bag[0]);
  }
  auto bag_h = pre_hash(bag);
  auto flipped_h = pre_hash(flipped);
  int desired_length = m - 1;
  auto desired_hash = eval_hash(bag_h, desired_length);
  vector<int> ans;
  for (int check : checks) {
    auto cur_hash = eval_hash(flipped_h, check, check + desired_length);
    if (cur_hash == desired_hash) {
      ans.push_back((m + m - 1 - check) % m);
    }
  }
  sort(ans.begin(), ans.end());
  printf("%d\n", (int)ans.size());
  for (int x : ans) {
    printf("%d ", x);
  }
  printf("\n");
  return 0;
}
