#include <bits/stdc++.h>
using namespace std;
int a[200000];
int b[200000];
int main(int argc, char *argv[]) {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  for (int i = 0; i < n - 1; ++i) b[i] = a[i + 1] - a[i];
  int t = n;
  for (int i = 1; i < n; ++i) {
    bool flag = true;
    for (int j = 0; j < n - i - 1; ++j) {
      if (b[j] != b[j + i]) {
        flag = false;
        break;
      }
    }
    if (flag) {
      t = i;
      break;
    }
  }
  int ans = -1;
  for (int i = 0; i < n; ++i) {
    int v = a[0] + a[i];
    if (v >= m && i < n - 1) continue;
    bool flag = false;
    for (int j = 1; j <= (i >> 1); ++j) {
      if (a[j] + a[i - j] != v) {
        flag = true;
        break;
      }
    }
    if (!flag) {
      for (int j = i + 1; j <= ((n + i) >> 1); ++j) {
        if (a[j] + a[n - j + i] != v + m) {
          flag = true;
          break;
        }
      }
    }
    if (!flag) {
      ans = i;
      break;
    }
  }
  if (ans == -1)
    cout << 0 << endl;
  else {
    int cnt = (n - 1 - ans) / t;
    cout << cnt + 1 << endl;
    int *res = new int[cnt + 1];
    for (int i = 0; i <= cnt; ++i) {
      res[i] = (a[0] + a[ans + i * t]) % m;
    }
    sort(res, res + cnt + 1);
    for (int i = 0; i < cnt; ++i) printf("%d ", res[i]);
    cout << res[cnt] << endl;
  }
  return 0;
}
