#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if (b == 0) {
    return a;
  } else {
    return gcd(b, a % b);
  }
}
long long int lcm(long long int a, long long int b) {
  return (a * b) / gcd(a, b);
}
long long int power(long long int a, long long int b) {
  if (b == 0) return 1;
  if (b == 1) return a;
  if (b % 2 == 1) return (power(a, b - 1) * a) % 1000000007;
  long long int q = power(a, b / 2);
  return (q * q) % 1000000007;
}
int main() {
  std::ios::sync_with_stdio(false);
  long long int n, k;
  cin >> n >> k;
  long long int arr[n + 2];
  set<long long int> se;
  long long int g = k;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    g = gcd(g, arr[i]);
  }
  vector<long long int> vec;
  for (int i = 0; i < k; i += g) vec.push_back(i);
  cout << vec.size() << "\n";
  for (int i = 0; i < vec.size(); i++) cout << vec[i] << " ";
  cout << "\n";
  return 0;
}
