#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1, ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
inline void writeln(long long x) {
  write(x);
  puts("");
}
const long long N = 3e5 + 5;
long long fac[N], n, m, c[N], ans, a[N], b[N], p = 569, ha1[N], ha2[N];
inline void init() {
  n = read();
  m = read();
  for (long long i = 1; i <= n; i++) a[i] = read();
  for (long long i = 1; i < n; i++) b[i] = a[i + 1] - a[i];
  fac[0] = 1;
  for (long long i = 1; i <= n; i++) fac[i] = fac[i - 1] * p;
  for (long long i = 1; i < n; i++) ha1[i] = ha1[i - 1] * p + b[i];
  for (long long i = n - 1; i; i--) ha2[i] = ha2[i + 1] * p + b[i];
}
bool flag;
inline long long has1(long long l, long long r) {
  return ha1[r] - ha1[l - 1] * fac[r - l + 1];
}
inline long long has2(long long l, long long r) {
  return ha2[l] - ha2[r + 1] * fac[r - l + 1];
}
inline bool judge(long long l, long long r) { return has1(l, r) == has2(l, r); }
inline void solve() {
  for (long long i = 1; i <= n; i++) {
    flag = 1;
    if (i > 1) flag &= judge(1, i - 1);
    if (i < n) {
      flag &= a[1] + a[i] + m == a[i + 1] + a[n];
      if (i != n - 1) flag &= judge(i + 1, n - 1);
    }
    if (flag) {
      c[++ans] = (a[1] + a[i]) % m;
    }
  }
  sort(c + 1, c + 1 + ans);
  writeln(ans);
  for (long long i = 1; i <= ans; i++) write(c[i]), putchar(' ');
}
signed main() {
  init();
  solve();
  return 0;
}
