#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  long long n, m;
  cin >> n >> m;
  vector<int> v(n);
  vector<long long> pref(n + 1);
  pref[0] = 0;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    pref[i + 1] = pref[i] + v[i];
  }
  vector<int> ans;
  for (int i = 0; i < n; i++) {
    long long sum = v[i] + v[0];
    if (sum >= m && i < n - 1) continue;
    bool f = 1;
    int cnt = 0;
    if (i % 2 == 0) cnt += v[i / 2];
    for (int l = 0; l < min(10, (i / 2 + 1)); l++) {
      if (pref[i - l + 1] - pref[l] + cnt != sum * (i / 2 - l + 1)) {
        f = 0;
        break;
      }
    }
    cnt = 0;
    if ((n - i) % 2 == 0) cnt += v[(n + i) / 2];
    if (f && i < n - 1)
      for (int l = 0; l < min((long long)10, ((n - i) / 2)); l++) {
        if (pref[n - l] - pref[l + i + 1] + cnt !=
            (sum + m) * ((n - i) / 2 - l)) {
          f = 0;
          break;
        }
      }
    if (f) ans.push_back(sum % m);
  }
  sort(ans.begin(), ans.end());
  cout << ans.size() << '\n';
  for (int i : ans) cout << i << ' ';
}
