#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
long long gcd(long long a, long long b) {
  long long c;
  while (a != 0) {
    c = a;
    a = b % a;
    b = c;
  }
  return b;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N, K;
  cin >> N >> K;
  vector<long long> A(N);
  long long g = K;
  for (long long i = 0; i < N; i++) {
    cin >> A[i];
    g = gcd(A[i], g);
  }
  cout << (K / g) << endl;
  for (long long i = 0; i < K / g; i++) {
    if (i > 0) cout << " ";
    cout << i * g;
  }
  cout << endl;
}
