#include <bits/stdc++.h>
using namespace std;
const int N = 400005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;
const int p = 1111111111;
int n, m;
int a[N];
int b[N];
long long pp[N];
long long h[N], hr[N];
set<int> answ;
set<int>::iterator it;
long long calc(int l, int r) { return h[r] - h[l - 1] * pp[r - l + 1]; }
long long calcr(int l, int r) { return hr[r] - hr[l - 1] * pp[r - l + 1]; }
int solve(int l, int r) {
  if (l == r) return (a[l] + 0ll + a[l]) % m;
  --r;
  if (calc(l, r) != calcr(2 * n - r, 2 * n - l)) return -1;
  return (a[l] + 0ll + a[r + 1]) % m;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    a[i + n] = m + a[i];
  }
  if (n == 1) {
    cout << 1 << endl;
    cout << (a[1] + a[1]) % m << endl;
    return 0;
  }
  pp[0] = 1;
  for (int i = 1; i <= 2 * n; i++) {
    pp[i] = pp[i - 1] * 1ll * p;
  }
  for (int i = 1; i < 2 * n; i++) b[i] = a[i + 1] - a[i];
  for (int i = 1; i < 2 * n; i++) {
    h[i] = h[i - 1] * 1ll * p + b[i];
  }
  for (int i = 2 * n - 1; i >= 1; i--) {
    int id = 2 * n - i;
    hr[id] = hr[id - 1] * 1ll * p + b[i];
  }
  for (int i = 1; i <= n; i++) {
    int l = i, r = i + n - 2;
    if (calc(l, r) == calcr(2 * n - r, 2 * n - l)) {
      answ.insert((a[i] + 0ll + a[i + n - 1]) % m);
    }
  }
  if (m % 2 == 0) {
    int id = 0;
    for (int i = 1; i <= n; i++) {
      if (a[i] < m / 2)
        id = i;
      else
        break;
    }
    if (id > 0 && id < n) {
      int A = solve(1, id);
      int B = solve(id + 1, n);
      if (A != -1 && A == B) {
        answ.insert(A);
      }
    }
  }
  cout << (int)answ.size() << endl;
  for (it = answ.begin(); it != answ.end(); ++it) {
    cout << *it << " ";
  }
  if ((int)answ.size()) cout << endl;
  return 0;
}
