#include <bits/stdc++.h>
using namespace std;
int a, b, i, u[444444], sz, ch[444444], arr[222222], x[444444];
int N, A[888888];
int S[888888];
void Manachers() {
  int r = 0, p = 0;
  for (int i = 1; i <= N; i++) {
    if (i <= r)
      A[i] = min(A[2 * p - i], r - i);
    else
      A[i] = 0;
    while (i - A[i] - 1 > 0 && i + A[i] + 1 <= N &&
           S[i - A[i] - 1] == S[i + A[i] + 1])
      A[i]++;
    if (r < i + A[i]) r = i + A[i], p = i;
  }
}
int main() {
  scanf("%d%d", &a, &b);
  for (i = 0; i < a; i++) {
    scanf("%d", &arr[i]);
  }
  x[a - 1] = (arr[0] - arr[a - 1] + b);
  for (i = a - 2; i >= 0; i--) x[i] = arr[i + 1] - arr[i];
  for (i = a; i < 2 * a; i++) x[i] = x[i - a];
  N = 4 * a - 1;
  for (i = 1; i <= N; i++) {
    if (i % 2 == 0)
      S[i] = -1;
    else
      S[i] = x[i / 2];
  }
  Manachers();
  for (i = 1; i <= 2 * a; i++) {
    if (A[i] != i - 1) ch[i % a] = 1;
  }
  for (i = 0; i < a; i++) {
    if (ch[i] == 0) u[sz++] = (arr[i] + arr[0]) % b;
  }
  sort(u, u + sz);
  printf("%d\n", sz);
  for (i = 0; i < sz; i++) printf("%d ", u[i]);
}
