#include <bits/stdc++.h>
using namespace std;
int gcdf(int a, int b) {
  if (b == 0) return a;
  return gcdf(b, a % b);
}
set<int> ans;
int main() {
  int n, k, gcd, a;
  cin >> n >> k;
  gcd = 0;
  for (int i = 0; i < n; i++) {
    cin >> a;
    gcd = gcdf(a % k, gcd);
  }
  for (int i = 0; i <= k; i++) {
    ans.insert((gcd * 1LL * i) % k);
  }
  cout << ans.size() << "\n";
  for (auto it = ans.begin(); it != ans.end(); it++) cout << (*it) << " ";
  cout << "\n";
  return 0;
}
