#include <bits/stdc++.h>
using namespace std;
int a[100010];
int gcd(int x, int y) {
  if (!y) return x;
  return gcd(y, x % y);
}
int main() {
  int n, m;
  ios::sync_with_stdio(false);
  cin >> n >> m;
  int d = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    d = gcd(d, a[i] % m);
  }
  if (d == 0) {
    cout << 1 << endl << 0 << endl;
    return 0;
  }
  set<int> st;
  for (int i = 1; i <= m; i++) {
    st.insert(1LL * i * d % m);
  }
  vector<int> ans;
  for (set<int>::iterator it = st.begin(); it != st.end(); it++)
    ans.push_back(*it);
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << " ";
  cout << endl;
  return 0;
}
