#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &t) {
  t = 0;
  char c = getchar();
  int f = 1;
  while (c < '0' || c > '9') {
    if (c == '-') f = -f;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    t = (t << 3) + (t << 1) + c - '0';
    c = getchar();
  }
  t *= f;
}
template <typename T, typename... Args>
inline void read(T &t, Args &...args) {
  read(t);
  read(args...);
}
template <typename T>
inline void write(T x) {
  if (x < 0) {
    x = -x;
    putchar('-');
  }
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
int n, m, p = 10007;
int a[200005];
unsigned long long pre[200005], nxt[200005], fac[200005];
unsigned long long gettoward(int l, int r) {
  return pre[r] - pre[l - 1] * fac[r - l + 1];
}
unsigned long long getreverse(int l, int r) {
  return nxt[l] - nxt[r + 1] * fac[r - l + 1];
}
bool check(int l, int r) { return gettoward(l, r) == getreverse(l, r); }
int top;
int sta[200005];
signed main() {
  read(n, m);
  for (register int i = 1; i <= n; ++i) read(a[i]);
  fac[0] = 1;
  for (register int i = 1; i <= n; ++i) fac[i] = fac[i - 1] * p;
  for (register int i = n - 1; i >= 1; --i)
    nxt[i] = nxt[i + 1] * p + a[i + 1] - a[i];
  for (register int i = 1; i <= n - 1; ++i)
    pre[i] = pre[i - 1] * p + a[i + 1] - a[i];
  for (register int i = 1; i <= n; ++i) {
    bool flag = 1;
    if (i > 1) flag &= check(1, i - 1);
    if (i < n) {
      flag &= a[1] + a[i] + m == a[i + 1] + a[n];
      if (i ^ n - 1) flag &= check(i + 1, n - 1);
    }
    if (flag) sta[++top] = (a[1] + a[i]) % m;
  }
  sort(sta + 1, sta + top + 1);
  write(top), putchar('\n');
  if (top == 0) return 0;
  for (register int i = 1; i <= top; ++i) write(sta[i]), putchar(' ');
  putchar('\n');
  return 0;
}
