#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long long B = uniform_int_distribution<int>(333, 999)(rng);
const long long MOD1 = 1792209677, MOD2 = 1211874137;
template <class T>
pair<T, T> operator+(const pair<T, T>& l, const pair<T, T>& r) {
  return {(l.first + r.first) % MOD1, (l.second + r.second) % MOD2};
}
template <class T>
pair<T, T> operator-(const pair<T, T>& l, const pair<T, T>& r) {
  return {(l.first - r.first + MOD1) % MOD1,
          (l.second - r.second + MOD2) % MOD2};
}
template <class T>
pair<T, T> operator*(const pair<T, T>& l, const T& r) {
  return {l.first * r % MOD1, l.second * r % MOD2};
}
template <class T>
pair<T, T> operator*(const pair<T, T>& l, const pair<T, T>& r) {
  return {l.first * r.first % MOD1, l.second * r.second % MOD2};
}
struct HashInterval {
  vector<pair<long long, long long> > hs, pw;
  HashInterval(string& str)
      : hs(str.length() + 1, pair<long long, long long>(0, 0)), pw(hs) {
    pw[0] = pair<long long, long long>(1, 1);
    for (int i = 0; i < (int)str.length(); i++) {
      hs[i + 1] = hs[i] * B + pair<long long, long long>(str[i], str[i]);
      pw[i + 1] = pw[i] * B;
    }
  }
  pair<long long, long long> hashInterval(int a, int b) {
    pair<long long, long long> ans = hs[b] - hs[a] * pw[b - a];
    return ans;
  }
};
long long A[N];
vector<long long> V1, V2;
pair<long long, long long> hs1[N], hs2[N], pw[N];
vector<long long> ANS;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  long long m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> A[i];
  }
  for (int i = 1; i <= n; i++) {
    A[n + i] = A[i] + m;
  }
  for (int i = 2; i <= 2 * n; i++) {
    V1.push_back(A[i] - A[i - 1]);
  }
  V2 = V1;
  reverse(V2.begin(), V2.end());
  pw[0] = make_pair(1, 1);
  for (int i = 1; i <= 2 * n; i++) {
    pw[i] = pw[i - 1] * B;
  }
  for (int i = 0; i < (int)V1.size(); i++) {
    hs1[i + 1] = hs1[i] * B + make_pair(V1[i], V1[i]);
    hs2[i + 1] = hs2[i] * B + make_pair(V2[i], V2[i]);
  }
  for (int i = 1; i <= n; i++) {
    if (hs1[n] - hs1[0] * pw[n] == hs2[n - i + n] - hs2[n - i] * pw[n]) {
      ANS.push_back((A[1] + A[i]) % m);
    }
  }
  cout << ANS.size() << "\n";
  if (ANS.size()) {
    sort(ANS.begin(), ANS.end());
    for (auto it : ANS) {
      cout << it << " ";
    }
    cout << "\n";
  }
  return 0;
}
