#include <bits/stdc++.h>
int gcd(int a, int b) {
  if (a < b) {
    std::swap(a, b);
  }
  while (b) {
    int rem = a % b;
    a = b, b = rem;
  }
  return a;
}
int main() {
  int n, k, a;
  std::cin >> n >> k >> a;
  int g = a % k;
  for (int i = 1; i < n; ++i) {
    std::cin >> a;
    g = gcd(a % k, g);
  }
  int c = gcd(k, g);
  std::cout << k / c << '\n';
  for (int i = 0; i < k; i += c) {
    std::cout << i << ' ';
  }
  return 0;
}
