#include <bits/stdc++.h>
using namespace std;
const int N = 200025;
const int64_t INF = 1e16;
const int MOD = 1000000007, K = 25;
int64_t modpow(int64_t e, int64_t p, int64_t m = MOD) {
  int64_t r = 1;
  for (e %= m; p; p >>= 1, e = e * e % m)
    if (p & 1) r = r * e % m;
  return r;
}
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int n, M;
  cin >> n >> M;
  vector<int> v(n), ans;
  queue<int> q;
  for (int &x : v) cin >> x;
  int H = 0;
  for (int x : v) H = (H + modpow(K, x)) % MOD;
  for (int x : v) q.push(M - x);
  vector<int> cand = v;
  for (int &x : cand) x = (x + v[0]) % M;
  sort(cand.begin(), cand.end());
  int nowh = 0;
  for (int x : v) nowh = (nowh + modpow(K, M - x)) % MOD;
  for (int x : cand) {
    while (q.size() && q.front() + x >= M) {
      int a = q.front();
      q.pop();
      nowh = (nowh - modpow(K, a) + MOD) % MOD;
      nowh = (nowh + modpow(K, a) * modpow(modpow(K, M), MOD - 2)) % MOD;
    }
    int h = nowh * modpow(K, x) % MOD;
    if (H == h) ans.emplace_back(x);
  }
  sort(ans.begin(), ans.end());
  cout << ans.size() << '\n';
  for (int x : ans) cout << x << ' ';
  cout << '\n';
}
