#include <bits/stdc++.h>
using namespace std;
int n, k, a[100010], gg, ans;
int gcd(int a, int b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  gg = a[1];
  for (int i = 2; i <= n; i++) {
    if (gg == 1) {
      break;
    }
    if (a[i] > gg) {
      gg = gcd(a[i], gg);
    } else {
      gg = gcd(gg, a[i]);
    }
  }
  if (gg > k) {
    gg = gcd(gg, k);
  } else {
    gg = gcd(k, gg);
  }
  ans = k / gg;
  printf("%d\n", ans);
  for (int i = 0; i < ans; i++) {
    printf("%d ", i * gg);
  }
  return 0;
}
