#include <bits/stdc++.h>
using namespace std;
void re(int &x) {
  x = 0;
  char ch = getchar();
  int b = 0;
  while (ch < '0' || ch > '9') {
    if (ch == '-') b = 1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  if (b == 1) x *= -1;
}
int n, k;
int a[110000], gd;
int gcd(int a, int b) {
  if (b == 0) return a;
  gcd(b, a % b);
}
int main() {
  re(n), re(k);
  gd = k;
  for (register int i = 1; i <= n; i++) {
    re(a[i]);
    gd = gcd(gd, a[i]);
  }
  printf("%d\n", k / gd);
  for (register int i = 0; i < k; i += gd) {
    printf("%d ", i);
  }
  return 0;
}
