#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 400007;
int n, m;
int a[MAXN];
int s[MAXN], t[MAXN];
int fail[MAXN];
int ans[MAXN], ka;
void init();
void input();
void work();
int main() {
  init();
  input();
  work();
}
void init() { ios::sync_with_stdio(false); }
void input() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
}
void work() {
  int sl = 0, tl = 0;
  for (int i = 1; i < n; ++i) s[sl++] = a[i + 1] - a[i];
  s[sl++] = a[1] + m - a[n];
  for (int i = 1; i < n - 1; ++i) s[sl++] = a[i + 1] - a[i];
  for (int i = n; i > 1; --i) t[tl++] = a[i] - a[i - 1];
  t[tl] = -1;
  fail[0] = -1;
  int f = 0;
  for (int i = 1; i <= tl; ++i) {
    fail[i] = f;
    if (t[i] == t[fail[i]]) fail[i] = fail[fail[i]];
    while ((~f) && t[i] != t[f]) f = fail[f];
    ++f;
  }
  int ni = 0;
  for (int i = 0; i < sl; ++i) {
    while ((~ni) && s[i] != t[ni]) ni = fail[ni];
    ++ni;
    if (ni == tl) ans[++ka] = (a[(i + 1) % n + 1] + a[1]) % m;
  }
  sort(ans + 1, ans + 1 + ka);
  printf("%d\n", ka);
  for (int i = 1; i <= ka; ++i) printf("%d ", ans[i]);
  putchar('\n');
}
