#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
int main() {
  ios::sync_with_stdio(false);
  long long n, k;
  cin >> n >> k;
  long long gcd_act = 0;
  for (int i = 0; i < n; ++i) {
    long long ai;
    cin >> ai;
    gcd_act = gcd(ai, gcd_act);
  }
  set<long long> possible;
  gcd_act %= k;
  for (int i = 0; i < k; ++i) {
    possible.insert((gcd_act * i) % k);
  }
  unsigned long long l = 1;
  cout << possible.size() << "\n";
  for (long long p : possible) {
    cout << p;
    if (l != possible.size()) {
      l++;
      cout << " ";
    }
  }
  cout << "\n";
}
