#include <bits/stdc++.h>
using namespace std;
const int M = 400005;
int read() {
  int x = 0, flag = 1;
  char c;
  while ((c = getchar()) < '0' || c > '9')
    if (c == '-') flag = -1;
  while (c >= '0' && c <= '9')
    x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  return x * flag;
}
int n, m, a[M], b[M], ss[M], f[M], rr, ct;
vector<int> t;
void manacher() {
  for (int i = 1; i <= n; i++) ss[i * 2] = b[i];
  for (int i = 1; i <= n; i++) ss[i * 2 - 1] = -1;
  ss[2 * n + 1] = -1;
  f[1] = 1, rr = 1, ct = 1;
  for (int i = 2; i <= 2 * n + 1; i++) {
    if (rr < i)
      f[i] = 1;
    else
      f[i] = min(rr - i + 1, f[2 * ct - i]);
    while (i + f[i] <= 2 * n + 1 && i - f[i] >= 1 &&
           ss[i + f[i]] == ss[i - f[i]])
      f[i]++;
    if (i + f[i] - 1 > rr) ct = i, rr = i + f[i] - 1;
  }
}
int chk(int l, int r) {
  if (l >= r) return 1;
  int cent = l + r;
  int ll = cent - f[cent] + 1, rr = cent + f[cent] - 1;
  if (ll <= 2 * l && rr >= 2 * r)
    return 1;
  else
    return 0;
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  for (int i = 1; i <= n; i++) b[i] = a[i] - a[i - 1];
  if (n == 1) {
    printf("1\n%d\n", (a[1] + a[1]) % m);
    return 0;
  }
  manacher();
  for (int i = 1; i < n; i++) {
    if ((a[1] + a[i]) % m == (a[i + 1] + a[n]) % m)
      if (chk(2, i) && chk(i + 2, n)) t.push_back((a[1] + a[i]) % m);
  }
  if (chk(2, n)) t.push_back((a[1] + a[n]) % m);
  sort(t.begin(), t.end());
  printf("%d\n", t.size());
  for (int i = 0; i < t.size(); i++) printf("%d ", t[i]);
}
