#include <bits/stdc++.h>
using namespace std;
long long N, M;
const long long p = 1000000007;
vector<long long> a;
vector<long long> difs;
vector<long long> hhash;
vector<long long> backhash;
set<long long> ans;
vector<long long> degs;
void check(int start, int end) {
  long long sum1 = hhash[end];
  if (start > 0) sum1 = (sum1 + p - hhash[start - 1]) % p;
  long long sum2 = backhash[start];
  if (end < 2 * N - 1) sum2 = (sum2 + p - backhash[end + 1]) % p;
  if ((sum1 * degs[2 * N - 1 - end] - sum2 * degs[start]) % p == 0) {
    ans.insert((a[start % N] + a[(end + 1) % N]) % M);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> N >> M;
  a.resize(N);
  hhash.resize(2 * N);
  backhash.resize(2 * N);
  degs.resize(2 * N);
  degs[0] = 1;
  for (int i = 1; i < 2 * N; i++) degs[i] = degs[i - 1] * (M + 1) % p;
  for (int i = 0; i < N; i++) cin >> a[i];
  for (int i = 0; i < 2 * N; i++)
    difs.push_back((a[(i + 1) % N] + M - a[i % N]) % M);
  hhash[0] = difs[0];
  long long current = M + 1;
  for (int i = 1; i < 2 * N; i++) {
    hhash[i] = (hhash[i - 1] + current * difs[i]) % p;
    current = (current * (M + 1)) % p;
  }
  backhash[2 * N - 1] = difs[2 * N - 1];
  current = M + 1;
  for (int i = 2 * N - 2; i >= 0; i--) {
    backhash[i] = (backhash[i + 1] + current * difs[i]) % p;
    current = (current * (M + 1)) % p;
  }
  for (int i = 0; i < N; i++) check(i, i + N - 1);
  for (int i = 0; i < N; i++) check(i, i + N - 2);
  cout << ans.size() << endl;
  for (auto it = ans.begin(); it != ans.end(); it++) cout << *it << ' ';
}
