#include <bits/stdc++.h>
using namespace std;
int n, k, a[200000], v[200000], b[200000];
int gcd(int a, int b) {
  if (b == 0)
    return (a);
  else
    return (gcd(b, a % b));
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  int x = a[1];
  for (int i = 2; i <= n; i++) {
    x = gcd(x, a[i]);
  }
  x = gcd(k, x);
  memset(v, 0, sizeof(v));
  int t = x;
  int num = 0;
  while (1) {
    if (v[x % k]) break;
    num++;
    b[num] = x % k;
    v[x % k] = 1;
    x += t;
  }
  sort(b + 1, b + 1 + num);
  printf("%d\n", num);
  for (int i = 1; i <= num; i++) printf("%d ", b[i]);
  return (0);
}
