#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 11;
set<int> ans;
int n, m, len;
int a[N], b[N], c[N], p[N];
inline void manacher() {
  c[0] = -2;
  for (register int i = 0; i <= n + n - 2; ++i) c[++len] = b[i], c[++len] = -1;
  c[len + 1] = -3;
  int id = 0, mx = 0;
  for (register int i = 1; i <= len; ++i) {
    if (mx > i)
      p[i] = min(mx - i, p[id + id - i]);
    else
      p[i] = 1;
    while (c[i + p[i]] == c[i - p[i]]) ++p[i];
    if (p[i] + i > mx) id = i, mx = i + p[i];
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (register int i = 0; i <= n - 1; ++i) scanf("%d", a + i);
  sort(a, a + n);
  for (register int i = 1; i <= n; ++i)
    b[i - 1] = (a[i % n] - a[i - 1] + m) % m;
  for (register int i = 0; i <= n - 1; ++i) b[i + n] = b[i];
  manacher();
  for (int i = 2; i <= len; i += 2)
    if (p[i] / 2 >= n / 2 &&
        (a[(i / 2 - 1 + n) % n] + a[(i / 2 + 1) % n]) % m ==
            a[i / 2 % n] * 2 % m)
      ans.insert(a[i / 2 % n] * 2 % m);
  if (n % 2 == 0) {
    for (int i = 1; i <= len; i += 2)
      if (p[i] >= n) ans.insert((a[i / 2 % n] + a[(i / 2 + 1) % n]) % m);
  }
  printf("%d\n", ans.size());
  for (auto v : ans) printf("%d ", v);
  return 0;
}
