#include <bits/stdc++.h>
using namespace std;
const int RLEN = 1 << 18 | 1;
inline char nc() {
  static char ibuf[RLEN], *ib, *ob;
  (ib == ob) && (ob = (ib = ibuf) + fread(ibuf, 1, RLEN, stdin));
  return (ib == ob) ? -1 : *ib++;
}
inline int rd() {
  char ch = nc();
  int i = 0, f = 1;
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = nc();
  }
  while (isdigit(ch)) {
    i = (i << 1) + (i << 3) + ch - '0';
    ch = nc();
  }
  return i * f;
}
const pair<unsigned long long, int> base(31, 37);
const int mod = 1e9 + 7;
inline pair<unsigned long long, int> operator+(
    const pair<unsigned long long, int> &a,
    const pair<unsigned long long, int> &b) {
  return pair<unsigned long long, int>(a.first + b.first,
                                       (a.second + b.second) % mod);
}
inline pair<unsigned long long, int> operator-(
    const pair<unsigned long long, int> &a,
    const pair<unsigned long long, int> &b) {
  return pair<unsigned long long, int>(a.first - b.first,
                                       (a.second - b.second) % mod);
}
inline pair<unsigned long long, int> operator*(
    const pair<unsigned long long, int> &a,
    const pair<unsigned long long, int> &b) {
  return pair<unsigned long long, int>(a.first * b.first,
                                       (long long)a.second * b.second % mod);
}
const int N = 2e5 + 50;
pair<unsigned long long, int> pw[N], pre[N], suf[N];
int n, a[N], M;
map<int, int> mp;
int main() {
  n = rd(), M = rd();
  for (int i = 1; i <= n; i++) a[i] = rd();
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) mp[a[i]] = i;
  pw[0] = pair<unsigned long long, int>(1, 1);
  for (int i = 1; i <= n; i++) pw[i] = pw[i - 1] * base;
  for (int i = 2; i <= n; i++)
    pre[i] = pre[i - 1] * base +
             pair<unsigned long long, int>(a[i] - a[i - 1], a[i] - a[i - 1]);
  for (int i = n - 1; i >= 1; i--)
    suf[i] = suf[i + 1] + pw[n - i - 1] * pair<unsigned long long, int>(
                                              a[i + 1] - a[i], a[i + 1] - a[i]);
  vector<int> vec;
  pair<unsigned long long, int> hv(0, 0);
  for (int i = 2; i <= n; i++)
    hv = hv + pw[i - 2] * pair<unsigned long long, int>(a[i] - a[i - 1],
                                                        a[i] - a[i - 1]);
  for (int i = 1; i <= n; i++) {
    pair<unsigned long long, int> tar;
    if (i != n)
      tar = suf[i + 1] * pw[i] +
            pair<unsigned long long, int>(a[1] - a[n] + M, a[1] - a[n] + M) *
                pw[i - 1] +
            pre[i];
    else
      tar = suf[1];
    if (hv == tar) vec.push_back((a[1] + a[i]) % M);
  }
  sort(vec.begin(), vec.end());
  printf("%d\n", vec.size());
  for (int i = 0; i < vec.size(); ++i) printf("%d ", vec[i]);
}
