#include <bits/stdc++.h>
using namespace std;
int N, M;
int A[400005], Diff[400005];
const int Base = 73, MOD = 1000000007;
vector<int> Sol;
int power;
int h;
void completeA() {
  for (int i = 1; i <= N; i++) A[i + N] = A[i];
}
void precalcPower() {
  power = 1;
  for (int i = 1; i <= N - 2; i++) power = (1LL * power * Base) % MOD;
}
int takeToInterval(int x, int M) {
  if (x < 0) return x + M;
  if (x >= M) return x - M;
  return x;
}
void precalcDiff() {
  for (int i = 2; i <= N * 2; i++) {
    Diff[i] = takeToInterval(A[i] - A[i - 1], M);
  }
}
void computeHash() {
  for (int i = 2; i <= N; i++) {
    h = (1LL * h * Base + Diff[i]) % MOD;
  }
}
int startingH() {
  int ans = 0;
  for (int i = N * 2 - 1; i > N; i--) {
    ans = (1LL * ans * Base + Diff[i]) % MOD;
  }
  return ans;
}
int Roll(int currH, int pos) {
  currH -= (1LL * power * Diff[pos + N - 1]) % MOD;
  currH = takeToInterval(currH, MOD);
  currH = (1LL * currH * Base) % MOD;
  currH += Diff[pos];
  return takeToInterval(currH, MOD);
}
void Read() {
  scanf("%d%d", &N, &M);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &A[i]);
  }
}
void Solve() {
  int curr = startingH();
  for (int i = 2 * N - 1; i >= N; i--) {
    if (curr == h) Sol.push_back(takeToInterval(A[1] + A[i], M));
    curr = Roll(curr, i - N + 1);
  }
}
void Print() {
  printf("%d\n", (int)Sol.size());
  sort(Sol.begin(), Sol.end());
  for (int i = 0; i < Sol.size(); i++) {
    printf("%d ", Sol[i]);
  }
  printf("\n");
}
int main() {
  Read();
  completeA();
  precalcDiff();
  precalcPower();
  computeHash();
  Solve();
  Print();
  return 0;
}
