#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>
void printvec(vector<T>& vec) {
  for (int i = 0; i < vec.size(); i++) {
    cout << vec[i] << " ";
  }
  cout << endl;
}
long long a[412345];
long long diff[412345];
long long s[412345], t[412345];
long long lcp[412345], pos[412345];
signed main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m;
  cin >> n >> m;
  long long i, j;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  if (n == 1) {
    cout << 1 << endl;
    cout << (a[0] + a[0]) % m << endl;
    return 0;
  }
  for (i = 0; i < n; i++) {
    diff[i] = a[(i + 1) % n] - a[i];
    diff[i] %= m;
    diff[i] += m;
    diff[i] %= m;
  }
  for (i = 0; i < 2 * n; i++) {
    s[i] = diff[i % n];
  }
  for (i = 0; i < n - 1; i++) {
    t[n - 2 - i] = diff[i];
  }
  long long tlen = n - 1;
  long long slen = 2 * n;
  i = 1;
  j = 0;
  lcp[0] = 0;
  while (i < tlen) {
    if (t[i] == t[j]) {
      lcp[i] = j + 1;
      j++;
      i++;
    } else {
      if (j == 0) {
        lcp[i] = 0;
        i++;
      } else {
        j = lcp[j - 1];
      }
    }
  }
  i = 0;
  j = 0;
  while (i < slen) {
    if (s[i] == t[j]) {
      i++;
      j++;
    } else {
      if (j == 0) {
        i++;
      } else {
        j = lcp[j - 1];
      }
    }
    if (j == tlen) {
      pos[i - 1] = 1;
      j = lcp[j - 1];
    }
  }
  long long cnt = 0;
  for (i = n - 1; i < 2 * n - 1; i++) {
    if (pos[i] == 1) {
      cnt++;
    }
  }
  cout << cnt << endl;
  vector<long long> vec;
  for (i = n - 1; i < 2 * n - 1; i++) {
    if (pos[i]) {
      vec.push_back((a[i + 1 - n] + a[0]) % m);
    }
  }
  sort(vec.begin(), vec.end());
  for (i = 0; i < vec.size(); i++) {
    cout << vec[i] << " ";
  }
  return 0;
}
