#include <bits/stdc++.h>
using namespace std;
void use_cio() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}
template <typename... Args>
void dbg(Args... args) {
  ((cout << args << " "), ...);
  cout << "\n";
}
int n, m;
long long a[200010];
int fail[200010];
vector<int> b, c;
vector<int> ans, rans;
int main() {
  use_cio();
  cin >> n >> m;
  for (int i = 0; i < (n); i++) cin >> a[i];
  for (int i = 0; i < (n); i++) b.push_back(((a[(i + 1) % n] - a[i]) + m) % m);
  for (int i = 0; i < (n); i++) c.push_back(b[i]);
  for (int i = 0; i < (n); i++) c.push_back(b[i]);
  reverse(c.begin(), c.end());
  int i = 0, j = -1;
  fail[i] = j;
  while (i < n) {
    while (j >= 0 && b[i] != b[j]) j = fail[j];
    i++, j++;
    fail[i] = j;
  }
  i = j = 0;
  while (i < 2 * n - 1) {
    while (j >= 0 && c[i] != b[j]) j = fail[j];
    i++, j++;
    if (j == n) {
      ans.push_back(i - j);
      j = fail[j];
    }
  }
  cout << (int)ans.size() << "\n";
  for (auto x : ans) {
    if (x == 0)
      rans.push_back((2 * a[0]) % m);
    else
      rans.push_back((a[0] + a[n - x]) % m);
  }
  sort(rans.begin(), rans.end());
  for (auto x : rans) cout << x << " ";
}
