#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  int v = 0, f = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = v * 10 + c - '0';
  while (isdigit(c = getchar())) v = v * 10 + c - '0';
  x = v * f;
}
inline void read(long long &x) {
  long long v = 0ll, f = 1ll;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = v * 10 + c - '0';
  while (isdigit(c = getchar())) v = v * 10 + c - '0';
  x = v * f;
}
inline void readc(char &x) {
  char c;
  while ((c = getchar()) == ' ')
    ;
  x = c;
}
inline void writes(string s) { puts(s.c_str()); }
inline void writeln() { writes(""); }
inline void writei(int x) {
  if (x < 0) {
    putchar('-');
    x = abs(x);
  }
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
inline void writell(long long x) {
  if (x < 0) {
    putchar('-');
    x = abs(x);
  }
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
int n, m, i, j, a[200005], b[200005];
unsigned long long e = 41793404541ull, lys[200005], csc[200005], pw[200005];
vector<int> ans;
unsigned long long tlysc(int x, int y) {
  return lys[y] - lys[x - 1] * pw[y - x + 1];
}
unsigned long long tcscc(int x, int y) {
  return csc[x] - csc[y + 1] * pw[y - x + 1];
}
int main() {
  ios_base::sync_with_stdio(false);
  ;
  cin >> n >> m;
  for (((i)) = (1); ((i)) <= ((n)); ((i))++) cin >> a[i];
  for (((i)) = (1); ((i)) <= ((n - 1)); ((i))++) b[i] = a[i + 1] - a[i];
  for (((i)) = (1); ((i)) <= ((n - 1)); ((i))++) lys[i] = lys[i - 1] * e + b[i];
  for (((i)) = ((n - 1)); ((i)) >= (1); ((i))--) csc[i] = csc[i + 1] * e + b[i];
  pw[0] = 1;
  for (((i)) = (1); ((i)) <= ((n)); ((i))++) pw[i] = pw[i - 1] * e;
  a[n + 1] = a[1];
  for (((i)) = (1); ((i)) <= ((n)); ((i))++) {
    if (i > 1 && tlysc(1, i - 1) != tcscc(1, i - 1)) continue;
    if (i < n - 1 && tlysc(i + 1, n - 1) != tcscc(i + 1, n - 1)) continue;
    if ((a[1] + a[i]) % m != (a[i + 1] + a[n]) % m) continue;
    ans.push_back((a[1] + a[i]) % m);
  }
  stable_sort((ans).begin(), (ans).end());
  ans.resize(unique((ans).begin(), (ans).end()) - ans.begin());
  printf("%d\n", (int)ans.size());
  for (__typeof((ans).begin()) itcalc = (ans).begin(); itcalc != (ans).end();
       itcalc++)
    printf("%d ", *itcalc);
  return 0;
}
