#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
void pre() {}
void solve() {}
vector<int> p[2];
void manacher(const vector<int>& s) {
  int n = (int)(s).size();
  p[0] = vector<int>(n + 1, 0);
  p[1] = vector<int>(n, 0);
  for (int z = 0; z < (2); ++z)
    for (int i = 0, l = 0, r = 0; i < n; i++) {
      int t = r - i + !z;
      if (i < r) p[z][i] = min(t, p[z][l + t]);
      int L = i - p[z][i], R = i + p[z][i] - !z;
      while (L >= 1 && R + 1 < n && s[L - 1] == s[R + 1]) p[z][i]++, L--, R++;
      if (R > r) l = L, r = R;
    }
}
bool check(int i, int j) {
  if (i < j) swap(i, j);
  if ((i - j + 1) % 2) {
    int k = (i + j) / 2;
    if (p[1][k] >= (i - j + 1) / 2) return 1;
    return 0;
  } else {
    int l = (i - j + 1) / 2;
    if (p[0][(i + j + 1) / 2] >= l) return 1;
    return 0;
  }
}
bool chk(int i, int j) {
  if (i >= j)
    return 1;
  else
    return check(i, j - 1);
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin.exceptions(cin.failbit);
  pre();
  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 << '\n';
    cout << (a[0] * 2) % m;
    return 0;
  }
  vector<int> d(n - 1);
  for (int i = 0; i < (n - 1); ++i) d[i] = a[i + 1] - a[i];
  manacher(d);
  vector<int> fns;
  for (int i = 0; i < (n); ++i) {
    if (i < n - 1) {
      if (chk(0, i) && chk(i + 1, n - 1) &&
          (a[0] + a[i]) % m == (a[i + 1] + a.back()) % m)
        fns.push_back((a[0] + a[i]) % m);
    } else {
      if (chk(0, n - 1)) fns.push_back((a[0] + a[n - 1]) % m);
    }
  }
  sort(fns.begin(), fns.end());
  cout << (int)(fns).size() << '\n';
  for (auto& i : fns) cout << i << ' ';
  return 0;
}
