#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200000;
const int INF = (long long)1e9 + 5;
int a[MAXN + 5], MOD;
vector<int> text, pat;
vector<int> kmp(vector<int> &text, vector<int> &pat) {
  int N = text.size(), M = pat.size();
  vector<int> lps(M);
  lps[0] = 0;
  for (int i = 1; i < M; i++) {
    int len = lps[i - 1];
    while (len > 0 && pat[len] != pat[i]) len = lps[len - 1];
    lps[i] = pat[i] == pat[len] ? len + 1 : 0;
  }
  int i = 0, j = 0;
  vector<int> ans;
  while (i < N) {
    if ((text[i] + pat[j]) % MOD == 0) {
      i++;
      j++;
      if (j == M) {
        j = lps[j - 1];
        ans.push_back(i - M);
      }
    } else if (j == 0) {
      i++;
    } else {
      j = lps[j - 1];
    }
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int N;
  cin >> N >> MOD;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    if (i != 0) pat.push_back(a[i] - a[i - 1]);
  }
  if (N == 1) {
    cout << "1\n" << a[0] * 2 % MOD << "\n";
    return 0;
  }
  text.resize(2 * N - 2);
  for (int i = 0; i < text.size(); i++) {
    int p1 = i % N, p2 = (p1 + 1) % N;
    p1 = N - p1 - 1, p2 = N - p2 - 1;
    text[i] = a[p2] - a[p1];
  }
  vector<int> ans = kmp(text, pat);
  for (int i = 0; i < ans.size(); i++) {
    int x = ans[i];
    ans[i] = (a[N - x - 1] + a[0]) % MOD;
  }
  sort(ans.begin(), ans.end());
  cout << ans.size() << "\n";
  for (int i = 0; i < ans.size(); i++)
    cout << ans[i] << (i + 1 < ans.size() ? ' ' : '\n');
}
