#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int n, k;
int a[MAXN], G;
int gcd(int A, int B) { return A % B == 0 ? B : gcd(B, A % B); }
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    a[i] = a[i] % k;
    if (a[i] == 0) {
      n--;
      i--;
    }
  }
  if (n == 0) {
    printf("1\n0\n");
    return 0;
  }
  G = k;
  for (int i = 1; i <= n; i++) {
    G = gcd(G, a[i]);
  }
  printf("%d\n", (k + G - 1) / G);
  for (int i = 0; i * G < k; i++) {
    printf("%d ", i * G);
  }
}
