#include <bits/stdc++.h>
using namespace std;
int mod;
vector<int> shiftArray(const vector<int>& v) {
  int n = v.size();
  vector<int> res(n, 0);
  int l = -1;
  int r = -1;
  for (int i = 1; i < n; ++i) {
    int k = v[0] - v[i];
    if (i <= r) res[i] = min(res[i - l], r - i);
    for (; (r <= i + res[i]) && (i + res[i] < n); ++res[i]) {
      if (v[res[i]] != k + v[i + res[i]]) break;
      l = i;
      r = i + res[i];
    }
  }
  return res;
}
vector<bool> getCans(const vector<int>& vals) {
  int n = vals.size();
  vector<int> rep(2 * n);
  for (int i = 0; i < n; ++i) rep[i] = vals[i];
  for (int i = 0; i < n; ++i) rep[2 * n - 1 - i] = -vals[i];
  vector<int> arr = shiftArray(rep);
  vector<bool> cans(n + 1, false);
  cans[0] = true;
  for (int len = 1; len <= n; ++len) {
    if (arr[2 * n - len] >= (len + 1) / 2) cans[len] = true;
  }
  return cans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n >> mod;
  vector<int> vals(n);
  vector<int> inv(n);
  for (int i = 0; i < n; ++i) cin >> vals[i];
  for (int i = 0; i < n; ++i) inv[i] = vals[n - 1 - i];
  vector<bool> pref_cans = getCans(vals);
  vector<bool> suff_cans = getCans(inv);
  reverse(suff_cans.begin(), suff_cans.end());
  vector<int> res;
  for (int len = 0; len <= n; ++len) {
    if (pref_cans[len] && suff_cans[len]) {
      if (len == 0 || len == n) {
        res.push_back((vals[0] + vals[n - 1]) % mod);
      } else {
        int pref_val = (vals[0] + vals[len - 1]) % mod;
        int suff_val = (vals[len] + vals[n - 1]) % mod;
        if (pref_val == suff_val) res.push_back(pref_val);
      }
    }
  }
  sort(res.begin(), res.end());
  res.erase(unique(res.begin(), res.end()), res.end());
  cout << res.size() << '\n';
  for (auto it : res) cout << it << ' ';
  cout << '\n';
}
