#include <bits/stdc++.h>
using namespace std;
const int N = 1000010, mod = 1e9 + 9, base = 19260817;
int n, m;
int a[N], b[N], p[N];
int h[N], h1[N];
int qp(int x, int k) {
  int res = 1;
  for (; k; k >>= 1, x = 1ll * x * x % mod)
    if (k & 1) res = 1ll * res * x % mod;
  return res;
}
int gh(int l, int r) {
  return (h[r] - 1ll * h[l - 1] * p[r - l + 1] % mod + mod) % mod;
}
int gh1(int l, int r) {
  return (h1[l] - 1ll * h1[r + 1] * p[r - l + 1] % mod + mod) % mod;
}
int ot[N];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  for (int i = n + 1; i <= 2 * n; i++) a[i] = a[i - n];
  for (int i = 1; i < n; i++) b[i] = a[i + 1] - a[i];
  for (int i = n; i < 2 * n; i++)
    b[i] = (a[i - n + 1] + m - a[(i - 1) % n + 1]) % m;
  p[0] = 1;
  for (int i = 1; i < 2 * n; i++) p[i] = 1ll * p[i - 1] * base % mod;
  for (int i = 1; i < 2 * n; i++) h[i] = (1ll * h[i - 1] * base + b[i]) % mod;
  for (int i = 2 * n - 1; i; i--) h1[i] = (1ll * h1[i + 1] * base + b[i]) % mod;
  int ans = 0;
  if (n & 1) {
    for (int i = n / 2 + 1; i <= n + n / 2; i++)
      if (gh(i - n / 2, i - 1) == gh1(i + 1, i + n / 2))
        ot[++ans] = (a[i + 1] + a[i]) % m;
    printf("%d\n", ans);
    sort(ot + 1, ot + ans + 1);
    for (int i = 1; i <= ans; i++) printf("%d ", ot[i]);
    return 0;
  }
  for (int i = n / 2; i < n; i++)
    if (gh(i - n / 2 + 1, i - 1) == gh1(i + 1, i + n / 2 - 1))
      ot[++ans] = (a[i] + a[i + 1]) % m;
  for (int i = n / 2; i < n; i++)
    if (gh(i - n / 2 + 1, i) == gh1(i + 1, i + n / 2))
      ot[++ans] = (a[i + 1] * 2) % m;
  printf("%d\n", ans);
  sort(ot + 1, ot + ans + 1);
  for (int i = 1; i <= ans; i++) printf("%d ", ot[i]);
  return 0;
}
