#include <bits/stdc++.h>
using namespace std;
static inline void canhazfast() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
}
template <typename T>
T gcd(T a, T b) {
  return b == 0 ? a : gcd(b, a % b);
}
template <typename T>
T extgcd(T a, T b, T &x, T &y) {
  T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
  while (b) {
    T q = a / b;
    a %= b;
    swap(a, b);
    x0 -= q * x1;
    swap(x0, x1);
    y0 -= q * y1;
    swap(y0, y1);
  }
  x = x0;
  y = y0;
  return a;
}
static inline int ctz(unsigned x) { return __builtin_ctz(x); }
static inline int ctzll(unsigned long long x) { return __builtin_ctzll(x); }
static inline int clz(unsigned x) { return __builtin_clz(x); }
static inline int clzll(unsigned long long x) { return __builtin_clzll(x); }
static inline int popcnt(unsigned x) { return __builtin_popcount(x); }
static inline int popcntll(unsigned long long x) {
  return __builtin_popcountll(x);
}
static inline int bsr(unsigned x) { return 31 ^ clz(x); }
static inline int bsrll(unsigned long long x) { return 63 ^ clzll(x); }
int main() {
  canhazfast();
  static int a[200016], x[2 * 200016], y[200016], pf[200016];
  int n, m;
  vector<int> ans;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i + 1 < n; ++i) x[i] = a[i + 1] - a[i];
  x[n - 1] = a[0] + m - a[n - 1];
  for (int i = 0, j = n - 1; i < n; ++i, --j) x[n + i] = y[j] = x[i];
  for (int i = 1, k = 0; i < n; ++i) {
    while (k && y[i] != y[k]) k = pf[k];
    if (y[i] == y[k]) ++k;
    pf[i + 1] = k;
  }
  for (int i = 0, k = 0; i < 2 * n - 1; ++i) {
    while (k && x[i] != y[k]) k = pf[k];
    if (x[i] == y[k]) ++k;
    if (k == n) {
      ans.push_back((a[0] + a[i - k + 1]) % m);
      k = pf[k];
    }
  }
  sort((ans).begin(), (ans).end());
  cout << ans.size() << '\n';
  for (int v : ans) cout << v << ' ';
  return 0;
}
