#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + (int)(c - '0');
    c = getchar();
  }
  return x * f;
}
int a[500005];
int rs[500005];
unsigned long long ca[500005], base[500005], zhs[500005], fhs[500005];
int main() {
  int n = read(), mod = read();
  for (int i = 1; i <= n; ++i) {
    a[i] = read();
  }
  if (n == 1) {
    printf("1\n%d", 2 * a[1] % mod);
    return 0;
  }
  for (int i = n + 1; i <= 2 * n; ++i) {
    a[i] = a[i - n];
  }
  ca[1] = (a[1] - a[n] + mod) % mod;
  base[0] = 1;
  base[1] = 1000000007;
  for (int i = 2; i <= 2 * n; ++i) {
    ca[i] = (a[i] - a[i - 1] + mod) % mod;
    base[i] = base[i - 1] * base[1];
  }
  for (int i = 1; i <= 2 * n; ++i) {
    zhs[i] = zhs[i - 1] * base[1] + ca[i];
    fhs[i] = fhs[i - 1] * base[1] + ca[2 * n - i + 1];
  }
  int res = 0;
  for (int i = 1; i <= n; ++i) {
    if (zhs[(i + n + 1) / 2] - zhs[1] * base[(i + n + 1) / 2 - 1] ==
        fhs[2 * n - (i + n + 4) / 2 + 1] -
            fhs[n - i] * base[2 * n - (i + n + 4) / 2 - n + i + 1])
      rs[++res] = i;
  }
  printf("%d\n", res);
  for (int i = 1; i <= res; ++i) {
    rs[i] = (a[rs[i]] + a[1]) % mod;
  }
  sort(rs + 1, rs + 1 + res);
  for (int i = 1; i <= res; ++i) {
    printf("%d ", rs[i]);
  }
  return 0;
}
