#include <bits/stdc++.h>
using namespace std;
inline int gi() {
  int x;
  scanf("%d", &x);
  return x;
}
const int mod = 998244353;
int Base;
int pw[1000005], Pre[1000005], A[1000005], Aft[1000005], Num[1000005], n, m;
set<int> Ans;
inline bool Judge(int l, int r) {
  if (l > r) return true;
  int s_pre = Pre[r] - 1ll * pw[r - l + 1] * Pre[l - 1] % mod;
  int s_aft = Aft[l] - 1ll * pw[r - l + 1] * Aft[r + 1] % mod;
  return (s_pre + mod) % mod == (s_aft + mod) % mod;
}
inline int Get(int l, int r) {
  int len = (r - l + 1);
  if (len % 2 == 1)
    return 2 * Num[l + len / 2];
  else if (len % 2 == 0)
    return Num[l + len / 2] + Num[l + len / 2 - 1];
}
int main() {
  n = gi();
  m = gi();
  for (int i = 1; i <= n; i++) Num[i] = gi();
  sort(A + 1, A + n + 1);
  for (int i = 1; i <= n - 1; i++) A[i] = Num[i + 1] - Num[i];
  Base = 1989;
  pw[0] = 1;
  for (int i = 1; i <= n; i++) pw[i] = 1ll * pw[i - 1] * Base % mod;
  Pre[0] = 0;
  for (int i = 1; i <= n - 1; i++)
    Pre[i] = (1ll * Pre[i - 1] * Base % mod + A[i]) % mod;
  Aft[n] = 0;
  for (int i = n - 1; i >= 1; i--)
    Aft[i] = (1ll * Aft[i + 1] * Base % mod + A[i]) % mod;
  Ans.clear();
  if (Judge(1, n - 1)) Ans.insert(Get(1, n) % m);
  int D = (Num[1] + Num[1]) % mod;
  for (int i = 1; i <= n; i++) {
    if (2 * Num[i] % m != D) break;
    if (i == n) Ans.insert(2 * Num[i] % m);
  }
  int l1, l2, r1, r2;
  for (int r = 1; r <= n - 1; r++) {
    l1 = 1;
    r1 = r;
    l2 = r + 1;
    r2 = n;
    if (Get(l1, r1) + m == Get(l2, r2) && Judge(l1, r1 - 1) &&
        Judge(l2, r2 - 1))
      Ans.insert(Get(l1, r1) % m);
  }
  cout << (int)(Ans.size()) << endl;
  for (set<int>::iterator it = Ans.begin(); it != Ans.end(); it++)
    cout << (*it) << " ";
  cout << endl;
  return 0;
}
