#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = long double;
using pi = pair<ll, ll>;
using mi = map<ll, ll>;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f;
ll qpow(ll a, ll b, ll MOD = mod) {
  for (ll ans = 1;; a = a * a % MOD, b >>= 1) {
    if (b & 1) ans = ans * a % MOD;
    if (!b) return ans;
  }
}
ll inv(ll a, ll MOD = mod) { return qpow(a, MOD - 2, MOD); }
ll exgcd(ll a, ll b, ll &x, ll &y) {
  if (b == 0) {
    x = 1, y = 0;
    return a;
  }
  ll ret = exgcd(b, a % b, y, x);
  y -= a / b * x;
  return ret;
}
ll getInv(ll a, ll mod) {
  ll x, y;
  ll d = exgcd(a, mod, x, y);
  return d == 1 ? (x % mod + mod) % mod : -1;
}
using vi = vector<ll>;
const ll N = 4e5 + 5;
ll M = 1e9 + 7;
inline ll add(ll x, ll y) { return x + y >= M ? x + y - M : x + y; }
inline ll mul(ll x, ll y) { return x * y % M; }
inline ll sub(ll x, ll y) { return x - y < 0 ? x - y + M : x - y; }
using G = vector<vi>;
namespace Manchaer {
template <typename T1>
void solve(T1 *s, ll n, vector<ll> &d1, vector<ll> &d2) {
  ll l = 0, r = -1;
  for (ll i = 0; i < n; ++i) {
    ll k = i > r ? 1 : min(r - i, d1[l + r - i]);
    while (0 <= i - k && i + k < n && s[i - k] == s[i + k]) k++;
    d1[i] = k--;
    if (i + k > r) {
      r = i + k;
      l = i - k;
    }
  }
  l = 0, r = -1;
  for (ll i = 0; i < n; ++i) {
    ll k = i > r ? 0 : min(r - i + 1, d2[l + r - i + 1]);
    while (0 <= i - k - 1 && i + k < n && s[i - k - 1] == s[i + k]) k++;
    d2[i] = k--;
    if (k > r) {
      r = k + i;
      l = i - k - 1;
    }
  }
}
}  // namespace Manchaer
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll n, m;
  cin >> n >> m;
  vector<ll> a(n, 0);
  for (ll &x : a) cin >> x;
  ll *b = new ll[n];
  for (ll i = 1; i <= n - 1; i++) b[i - 1] = a[i] - a[i - 1];
  vector<ll> d1(n, 0);
  vector<ll> d2(n, 0);
  Manchaer::solve(b, n - 1, d1, d2);
  vector<ll> ans;
  for (ll i = 0; i < n - 1; i++) {
    ll res = 1;
    if ((i + 1) % 2 == 0) {
      if (d2[(i + 1) / 2] >= (i + 1) / 2) res++;
    } else if (d1[i / 2] >= i / 2 + 1) {
      res++;
    }
    ll j = n - 2 - i - 1;
    if (j > 0) res--;
    if (j % 2 && j > 0) {
      if (d1[i + j / 2 + 2] >= j / 2 + 1) res++;
    } else if (j > 0 && d2[i + j / 2 + 2] >= j / 2)
      res++;
    if (res == 2 && j < 0)
      ans.emplace_back((a[0] + a[i + 1]) % m);
    else if (res == 2 && j >= 0 &&
             (a[0] + a[i + 1]) % m == (a[i + 2] + a[n - 1]) % m)
      ans.emplace_back((a[0] + a[i + 1]) % m);
  }
  if (n == 2 && (a[1] + a[1]) % m == (a[0] + a[0]) % m)
    ans.emplace_back((a[1] + a[1]) % m);
  else {
    ll k = (a[0] + a[0]) % m;
    ll tmp = 0;
    for (ll i = 1; i < n; i++) {
      if ((a[i] + a[n - i]) % m != k) tmp++;
    }
    if (!tmp) ans.emplace_back(k);
  }
  sort((ans).begin(), (ans).end());
  cout << ans.size() << '\n';
  for (ll &x : ans) cout << x << ' ';
  cout << '\n';
}
