#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 * 3 + 5;
int n, m;
int a[MAXN];
void read_input() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  sort(a, a + n);
}
int b[MAXN];
int str[4 * MAXN];
int cnt;
int z[4 * MAXN];
void z_function() {
  for (int i = 1, l = 0, r = 0; i < cnt; i++) {
    if (i <= r) {
      z[i] = min(z[i - l], r - i + 1);
    }
    while (z[i] + i < cnt && str[z[i]] == str[z[i] + i]) z[i]++;
    if (z[i] + i - 1 > r) {
      r = z[i] + i - 1;
      l = i;
    }
  }
}
int ans[MAXN];
int tr;
void solve() {
  b[0] = a[0] - a[n - 1];
  if (b[0] < 0) b[0] += m;
  for (int i = 1; i < n; i++) {
    b[i] = a[i] - a[i - 1];
    if (b[i] < 0) b[i] += m;
  }
  for (int i = n - 1; i >= 0; i--) {
    str[cnt++] = b[i];
  }
  str[cnt++] = -1;
  for (int i = 0; i < n; i++) {
    str[cnt++] = b[i];
  }
  for (int i = 0; i < n; i++) {
    str[cnt++] = b[i];
  }
  z_function();
  for (int i = 0; i < cnt; i++) {
    if (z[i] == n && i != n + 1) {
      int answ = a[n - 1] + a[i - n - 2];
      if (answ >= m) answ %= m;
      ans[tr++] = answ;
    }
  }
  printf("%d\n", tr);
  sort(ans, ans + tr);
  for (int i = 0; i < tr; i++) {
    printf("%d ", ans[i]);
  }
}
int main() {
  read_input();
  solve();
  return 0;
}
