#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  for (auto i = begin(v); i != end(v); i++)
    os << *i << (i == end(v) - 1 ? "" : " ");
  return os;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto i = begin(v); i != end(v); i++) is >> *i;
  return is;
}
template <int mod>
class ModNum {
 private:
  int num;
  inline int easy_mod(int value) const {
    while (value > mod) value -= mod;
    return value;
  }
  inline int int32_normalize(const int value) const {
    if (value < 0)
      return mod * (-value / mod + 1);
    else if (value >= mod)
      return value % mod;
    else
      return value;
  }

 public:
  ModNum(const int value) { num = int32_normalize(value); }
  ModNum(const long long value) { num = int32_normalize(value % mod); }
  operator int() const { return num; }
  ModNum& operator=(const ModNum<mod>& rhs) {
    this->num = rhs.num;
    return *this;
  }
  ModNum operator+(const ModNum& rhs) const {
    return ModNum(easy_mod(rhs.num + num));
  }
  ModNum& operator+=(const ModNum& rhs) {
    this->num = easy_mod(num + rhs.num);
    return *this;
  }
  ModNum operator-(const ModNum& rhs) const {
    return ModNum(easy_mod(num + mod - rhs.num));
  }
  ModNum& operator-=(const ModNum& rhs) {
    this->num = easy_mod(num + mod - rhs.num);
    return *this;
  }
  ModNum operator*(const int& rhs) const {
    long long x = (long long)num * rhs;
    return ModNum(x < mod ? x : (x % mod));
  }
  ModNum& operator*=(const int& rhs) {
    long long x = (long long)num * rhs;
    this->num = x < mod ? (int)x : (x % mod);
    return *this;
  }
  ModNum operator/(const ModNum& rhs) const { return div(rhs); }
  ModNum operator/(const int rhs) const { return div(rhs); }
  ModNum div(const ModNum& other) const {
    return (*this) * (other.pow(mod - 2));
  }
  ModNum div(const int& other) const { return div(ModNum(other)); }
  inline ModNum pow(const unsigned long long power) const {
    ModNum resp = 1;
    unsigned long long power2_value = 1;
    ModNum power2_mod = *this;
    while (power2_value <= power) {
      if (power & power2_value) resp *= power2_mod;
      power2_mod *= power2_mod;
      power2_value *= 2ULL;
    }
    return resp;
  }
  inline ModNum pow(const int power) const {
    return this->pow((const unsigned long long)power);
  }
};
template <int mod>
ModNum<mod> pow(ModNum<mod> base, int power) {
  return base.pow(power);
}
template <int mod, int pw>
vector<int> get_points(int n, int m, const vector<int>& ns) {
  vector<ModNum<mod> > from_l(n + 1, 0), from_r(n + 1, 0);
  vector<ModNum<mod> > memo_l(n + 1, 1);
  for (int i = 0; i < n; i++) {
    memo_l[i] = pow<mod>(pw, ns[i]);
    ;
    from_l[i] += memo_l[i];
    from_r[i] += pow<mod>(pw, m - ns[i]);
    if (i > 0) from_l[i] += from_l[i - 1];
  }
  for (int i = n - 2; i >= 0; i--) {
    from_r[i] += from_r[i + 1];
  }
  vector<int> cand;
  int ofs = ns[0];
  int rofs = m - ns.back();
  auto p_ofs = pow<mod>(pw, ofs);
  auto p_rofs = pow<mod>(pw, rofs);
  for (int i = 0; i < n; i++) {
    int val = ns[i] + ofs;
    if (i + 1 < n && (val + rofs != ns[i + 1])) continue;
    bool left_ok = true, right_ok = true;
    if (i > 0) {
      ModNum<mod> a = from_l[i] / p_ofs;
      ModNum<mod> b = (from_r[0] - from_r[i + 1]) / pow<mod>(pw, m - ns[i]);
      if (a != b) left_ok = right_ok = false;
    }
    if (i + 1 < n && left_ok) {
      ModNum<mod> a = (from_l[n - 1] - from_l[i]) / memo_l[i + 1];
      ModNum<mod> b = from_r[i + 1] / p_rofs;
      if (a != b) right_ok = false;
    }
    if (left_ok && right_ok) cand.push_back(val % m);
  }
  for (int i = 0; i + 1 < cand.size(); i++) {
    if (cand[i] > cand[i + 1]) {
      std::rotate(cand.begin(), cand.begin() + i + 1, cand.end());
      break;
    }
  }
  return cand;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  scanf("%d %d", &n, &m);
  vector<int> v(n);
  for (int i = 0; i < n; i++) scanf("%d", &v[i]);
  auto s1 = get_points<800007449, 33>(n, m, v);
  auto s2 = get_points<800004371, 47>(n, m, v);
  vector<int> ans;
  set_intersection((s1).begin(), (s1).end(), (s2).begin(), (s2).end(),
                   back_inserter(ans));
  printf("%d\n", ans.size());
  for (int x : ans) printf("%d ", x);
  return 0;
}
