#include <bits/stdc++.h>
using namespace std;
long long n, k;
long long bmm(long long x, long long y) {
  if (y) return bmm(y, x % y);
  return x;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  long long d = k;
  for (long long i = 0; i < n; i++) {
    long long x;
    cin >> x;
    d = bmm(d, x % k);
  }
  if (d == k) {
    cout << 1 << "\n";
    cout << 0 << "\n";
  } else {
    n = (k + d - 1) / d;
    cout << n << "\n";
    for (long long i = 0; i < n; i++) cout << i * d << " ";
    cout << "\n";
  }
  return 0;
}
