#include <bits/stdc++.h>
using namespace std;
inline long long read(long long out = 0) {
  char c;
  while ((c = getchar()) < 48 || c > 57)
    ;
  while (c >= 48 && c <= 57) out = out * 10 + c - 48, c = getchar();
  return out;
}
const long long M = 35;
const long long mod = 1e9 + 7;
const long long PP = 131;
const double eps = 1e-10;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
const long long N = 10000010;
long long a[N];
signed main() {
  long long n, m;
  cin >> n >> m;
  long long x;
  cin >> x;
  x %= m;
  long long ans = x;
  for (long long i = 2; i <= n; i++) {
    scanf("%lld", &a[i]);
    a[i] %= m;
    ans = gcd(ans, a[i]);
  }
  if (ans == 0) {
    cout << "1\n0" << endl;
    return 0;
  }
  ans = gcd(ans, m);
  ans %= m;
  cout << m / ans << endl;
  for (long long i = 0; i < m / ans; i++) cout << ans * i << " ";
  cout << endl;
  return 0;
}
