#include <bits/stdc++.h>
const int N = 300010, P = 998244353;
using namespace std;
int n, ans;
unsigned long long m, pre[N], suf[N], fac[N], a[N], b[N], c[N], p = 569;
unsigned long long work1(int l, int r) {
  return pre[r] - pre[l - 1] * fac[r - l + 1];
}
unsigned long long work2(int l, int r) {
  return suf[l] - suf[r + 1] * fac[r - l + 1];
}
int check(int l, int r) { return work1(l, r) == work2(l, r); }
int main() {
  int i, flag;
  scanf("%d%I64d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%I64d", &a[i]);
  for (int i = 1; i <= n; i++) b[i] = a[i + 1] - a[i];
  fac[0] = 1;
  for (int i = 1; i <= n; i++) fac[i] = fac[i - 1] * p;
  for (int i = 1; i < n; i++) pre[i] = (pre[i - 1] * p + b[i]);
  for (int i = n - 1; i; i--) suf[i] = (suf[i + 1] * p + b[i]);
  for (int i = 1; i <= n; i++) {
    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) c[++ans] = (a[1] + a[i]) % m;
  }
  sort(c + 1, c + ans + 1);
  printf("%d\n", ans);
  for (int i = 1; i <= ans; i++) printf("%I64d ", c[i]);
}
