#include <bits/stdc++.h>
using namespace std;
template <typename T>
vector<int> Zfunc(T s) {
  int n = s.size(), a = 0, b = 0;
  vector<int> z(n, 0);
  z[0] = n;
  for (int i = 1; i < n; i++) {
    int end = i;
    if (i < b) {
      end = min(i + z[i - a], b);
    }
    while (end < n && s[end] == s[end - i]) {
      end++;
    }
    z[i] = end - i;
    if (end > b) {
      a = i;
      b = end;
    }
  }
  return z;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  if (n <= 1) {
    cout << 1 << endl << (a[0] + a.back()) % m << endl;
    return 0;
  }
  vector<int> diff, rdiff;
  for (int i = 1; i < n; i++) {
    diff.push_back(a[i] - a[i - 1]);
  }
  rdiff = diff;
  reverse(rdiff.begin(), rdiff.end());
  for (int i = 0; i < n - 1; i++) {
    diff.push_back(rdiff[i]);
    rdiff.push_back(diff[i]);
  }
  vector<int> z = Zfunc<vector<int>>(diff), rz = Zfunc<vector<int>>(rdiff), ans;
  for (int i = 0; i < n; i++) {
    bool ncan = 1;
    if (i > 1) {
      ncan &= (z[2 * (n - 1) - (i - 1)] + 1 >= i);
    }
    if (i < n - 1) {
      ncan &= (rz[n - 1 + i] + 1 >= n - i);
    }
    if (ncan && i == 0) {
      ans.push_back((a[0] + a[n - 1]) % m);
    } else if (ncan && ((a[0] + a[i - 1]) % m == (a[i] + a[n - 1]) % m)) {
      ans.push_back((a[0] + a[i - 1]) % m);
    }
  }
  cout << (int)ans.size() << endl;
  sort(ans.begin(), ans.end());
  for (auto it : ans) {
    cout << it << ' ';
  }
  return 0;
}
