#include <bits/stdc++.h>
using namespace std;
long long n, k, nyan, tmp, i;
long long a[200007], ans[200007];
long long gcd(long long x, long long y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
int main() {
  scanf("%lld%lld", &n, &k);
  for (i = 0; i < n; i++) scanf("%lld", &a[i]);
  nyan = a[0];
  for (i = 0; i < n; i++) nyan = gcd(nyan, a[i]);
  nyan %= k;
  tmp = 0;
  for (i = 0; i <= 100001; i++) {
    ans[tmp] = true;
    tmp = (tmp + nyan) % k;
  }
  tmp = 0;
  for (i = 0; i <= 100000; i++)
    if (ans[i]) tmp++;
  printf("%lld\n", tmp);
  for (i = 0; i <= 100000; i++)
    if (ans[i]) printf("%lld ", i);
  printf("\n");
}
