#include <bits/stdc++.h>
using namespace std;
const int N = 200001;
const long long mod = 1000000007ll, K = 15ll;
int n, a[N];
int m;
long long prefix1[N], suffix1[N];
long long prefix2[N], suffix2[N];
vector<int> ans;
long long qpow(long long p, long long q) {
  long long res = 1 % mod;
  while (q) {
    if (q & 1) res = (res * p) % mod;
    q >>= 1, p = (p * p) % mod;
  }
  return res;
}
void init() {
  prefix1[0] = qpow(K, a[0]), prefix2[0] = qpow(K, mod - 1 - a[0]);
  for (int i = 1; i < n; i++) {
    prefix1[i] = (prefix1[i - 1] + qpow(K, a[i])) % mod;
    prefix2[i] = (prefix2[i - 1] + qpow(K, mod - 1 - a[i])) % mod;
  }
  suffix1[n] = 0ll, suffix2[n] = 0ll;
  for (int i = n - 1; i >= 0; i--) {
    suffix1[i] = (suffix1[i + 1] + qpow(K, a[i])) % mod;
    suffix2[i] = (suffix2[i + 1] + qpow(K, mod - 1 - a[i])) % mod;
  }
}
bool check(int num) {
  int l = -1, r = n - 1;
  while (l < r) {
    int mid = (l + r + 1) >> 1;
    if (a[mid] <= num)
      l = mid;
    else
      r = mid - 1;
  }
  if (l == -1) return suffix1[0] == (suffix2[0] * qpow(K, num + m)) % mod;
  return prefix1[l] == (prefix2[l] * qpow(K, num)) % mod &&
         suffix1[l + 1] == (suffix2[l + 1] * qpow(K, num + m)) % mod;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  init();
  for (int i = 0; i < n; i++) {
    if (check((a[0] + a[i]) % m)) ans.push_back((a[0] + a[i]) % m);
  }
  sort(ans.begin(), ans.end());
  int k = 0;
  for (int j = 0; j < ans.size(); j++)
    if (!j || ans[j] != ans[j - 1]) k++;
  printf("%d\n", k);
  for (int j = 0; j < ans.size(); j++)
    if (!j || ans[j] != ans[j - 1]) printf("%d ", ans[j]);
  printf("\n");
  return 0;
}
