#include <bits/stdc++.h>
using namespace std;
long long int gcd(int a, int b) {
  if (b == 0) return a;
  a %= b;
  return gcd(b, a);
}
int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  vector<int> v;
  long long int g = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    g = gcd(g, a[i]);
  }
  for (long long int i = 0; i < k; i++) {
    v.push_back((g * i) % k);
  }
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  cout << v.size() << endl;
  for (int i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
  cout << endl;
  return 0;
}
