#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable : 4996)
const int N = 2e5 + 5;
int a[N], d[N], w[N];
int n, m;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  pair<int, int> b, e;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n - 1; i++) {
    d[i] = a[i + 1] - a[i] - 1;
  }
  d[n - 1] = m;
  b = {0, a[0] - 1};
  e = {a[n - 1] + m, m * 2 - 1};
  set<int> st;
  for (int i = 0, l = -1, r = -1; i < n - 1; i++) {
    int k = 0;
    if (i <= r) {
      k = min(w[l + r - i - 1], r - i);
    }
    while (i - k >= 0 && i + k < n - 1 && d[i - k] == d[i + k]) k++;
    if (i - k == -1 && a[0] <= d[i + k] ||
        i + k == n - 1 && m - 1 - a[n - 1] <= d[i - k]) {
      st.insert(a[i] + a[i + 1]);
    }
    w[i] = k;
    if (i + k - 1 > r) {
      r = i + k - 1;
      l = i - k + 1;
    }
  }
  if (a[0] <= d[0]) {
    st.insert(a[0] * 2);
  }
  if (n == 1 && m - 1 - a[n - 1] <= a[0] ||
      n > 1 && m - 1 - a[n - 1] <= d[n - 2]) {
    st.insert(a[n - 1] * 2);
  }
  for (int i = 0, l = -1, r = -1; i < n - 2; i++) {
    int k = 0;
    if (i < r) {
      k = min(w[l + r - i], r - i - 1);
    }
    while (i - k >= 0 && i + k + 1 < n && d[i - k] == d[i + k + 1]) k++;
    w[i] = k;
    if (k > 0) {
      if (i - k == -1 && a[0] <= d[i + k + 1] ||
          i + k + 1 == n - 1 && m - 1 - a[n - 1] <= d[i - k]) {
        st.insert(a[i] + a[i + 2]);
      }
    }
    if (i + k > r) {
      r = i + k;
      l = i - k + 1;
    }
  }
  vector<int> ans;
  for (int x : st) {
    if (x >= m) {
      if (b.first <= x - m && b.second >= x - m) ans.push_back(x - m);
    } else {
      if (st.count(x + m) || e.first <= x + m && e.second >= x + m)
        ans.push_back(x);
    }
  }
  sort(ans.begin(), ans.end());
  cout << ans.size() << "\n";
  for (int x : ans) cout << x << " ";
  return 0;
}
