#include <bits/stdc++.h>
using ul = std::uint32_t;
using ull = std::uint64_t;
using li = std::int32_t;
using ll = std::int64_t;
using vul = std::vector<ul>;
ul n, m;
ul times(ul a, ul b) { return ull(a) * b % m; }
ul plus(ul a, ul b) { return a + b < m ? a + b : a + b - m; }
ul minus(ul a, ul b) { return a < b ? a + m - b : a - b; }
vul datas(2e5);
vul ans;
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  std::cin >> n >> m;
  ul k1 = 0;
  ul k2 = 0;
  ul k3 = 0;
  std::srand(std::time(0));
  datas.resize(n);
  for (ul i = 0; i != n; ++i) {
    std::cin >> datas[i];
    k1 = plus(k1, datas[i]);
    k2 = plus(k2, times(datas[i], datas[i]));
    k3 = plus(k3, times(datas[i], times(datas[i], datas[i])));
  }
  std::sort(datas.begin(), datas.end());
  for (ul i = 0; i != n; ++i) {
    ul t = plus(datas[i], datas[0]);
    if (times(t, n) != times(k1, 2)) {
      continue;
    }
    if (times(minus(times(t, times(t, n)), times(2, k2)), times(3, t)) !=
        times(minus(times(t, times(t, times(t, n))), times(2, k3)), 2)) {
      continue;
    }
    bool flag = true;
    for (ul j = 0; j != 100; ++j) {
      ul q = std::rand() % n;
      ul q2 = minus(t, datas[q]);
      ul it =
          std::lower_bound(datas.data(), datas.data() + n, q2) - datas.data();
      if (it == n || datas[it] != q2) {
        flag = false;
        break;
      }
    }
    if (flag) {
      ans.push_back(t);
    }
  }
  std::sort(ans.begin(), ans.end());
  ans.resize(std::unique(ans.begin(), ans.end()) - ans.begin());
  std::cout << ans.size() << std::endl;
  for (ul i = 0; i != ans.size(); ++i) {
    if (i) {
      std::cout << ' ';
    }
    std::cout << ans[i];
  }
  std::cout << std::endl;
  return 0;
}
