#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  x = 0;
  char c = getchar();
  int f = 1;
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  x *= f;
}
inline unsigned int R() {
  static unsigned int seed = 416;
  return seed ^= seed >> 5, seed ^= seed << 17, seed ^= seed >> 13;
}
const int N = 866666;
int n, m, a[N], v[N], p[N];
vector<int> Set;
void manacher(int n) {
  for (register int i = (n); i >= (1); i--) v[i * 2] = v[i], v[i * 2 + 1] = -1;
  v[1] = -1;
  int id = 0;
  for (register int i = (1); i <= (n * 2 + 1); i++) {
    if (id * 2 - i >= 1 && id + p[id] >= i)
      p[i] = min(p[id * 2 - i], id + p[id] - i);
    while (i + p[i] <= n * 2 + 1 && i - p[i] >= 1 && v[i + p[i]] == v[i - p[i]])
      p[i]++;
    if (p[i] + i > p[id] + id) id = i;
    if (i - p[i] + 1 == 3 && (i + p[i] - 1) / 2 >= n / 2) {
      Set.push_back((1LL * a[1] + a[(i + p[i] - 1) / 2]) % m);
    }
  }
}
int main() {
  read(n);
  read(m);
  for (register int i = (1); i <= (n); i++) read(a[i]);
  for (register int i = (1); i <= (n); i++) a[i + n] = a[i] + m;
  for (register int i = (1); i <= (n + n); i++) v[i] = a[i] - a[i - 1];
  v[1] = -233;
  manacher(n + n);
  sort(Set.begin(), Set.end());
  Set.erase(unique(Set.begin(), Set.end()), Set.end());
  printf("%d\n", ((int)Set.size()));
  for (register int i = (0); i <= (((int)Set.size()) - 1); i++)
    printf("%d ", Set[i]);
  return 0;
}
