#include <bits/stdc++.h>
const int MAXN = 100000;
int a[MAXN], N, K;
int gcd(int a, int b) { return !b ? a : gcd(b, a % b); }
void solve() {
  int g = a[0];
  for (int i = 1; i < N; ++i) g = gcd(g, a[i]);
  g = gcd(g, K);
  printf("%d\n", K / g);
  for (int i = 0; i < K; i += g) printf("%d ", i);
  printf("\n");
}
int main() {
  scanf("%d%d", &N, &K);
  for (int i = 0; i < N; ++i) scanf("%d", a + i);
  solve();
  return 0;
}
