#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 7, MOD = 1e9 + 7;
int a[MAXN], h[MAXN], pw[MAXN], n, m, b[MAXN], g[MAXN];
set<int> dels;
int geth(int l, int r) {
  if (l > r) return -1;
  return (1LL * h[r] - 1LL * h[l - 1] * pw[r - l + 1] + 1LL * MOD * MOD) % MOD;
}
int getg(int l, int r) {
  if (l > r) return -1;
  return (1LL * g[l] - 1LL * g[r + 1] * pw[r - l + 1] + 1LL * MOD * MOD) % MOD;
}
bool rev(int l, int r) { return (geth(l, r) == getg(l, r)); }
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  pw[0] = 1;
  for (int i = 1; i < n; ++i) {
    b[i] = a[i + 1] - a[i];
    h[i] = (1LL * h[i - 1] * m + b[i]) % MOD;
    pw[i] = 1LL * pw[i - 1] * m % MOD;
  }
  for (int i = n - 1; i >= 1; --i) {
    g[i] = (1LL * g[i + 1] * m + b[i]) % MOD;
  }
  if (rev(2, n - 1) && (2 * a[1] % m == (a[2] + a[n]) % m))
    dels.insert(2 * a[1] % m);
  if (rev(1, n - 2) && (2 * a[n] % m == (a[1] + a[n - 1]) % m))
    dels.insert(2 * a[n] % m);
  if (rev(1, n - 1)) dels.insert((a[1] + a[n]) % m);
  for (int i = 1; i + 2 < n; ++i) {
    if (rev(1, i) && rev(i + 2, n - 1) &&
        a[1] + a[i + 1] == (a[i + 2] + a[n]) % m)
      dels.insert(a[1] + a[i + 1]);
  }
  cout << (int)dels.size() << '\n';
  for (auto v : dels) cout << v << ' ';
  return 0;
}
