#include <bits/stdc++.h>
using namespace std;
int gc(int x, int y) {
  if (x > y) swap(x, y);
  if (x == 0) return y;
  y = y % x;
  return gc(y, x);
}
int main() {
  int n, k;
  int x;
  int g;
  vector<int> a;
  scanf("%d %d", &n, &k);
  g = k;
  for (int i = 0; i < int(n); i++) {
    scanf("%d", &x);
    x = x % k;
    g = gc(x, g);
  }
  x = 0;
  printf("%d\n", (k / g));
  for (int i = 0; i < int((k / g) - 1); i++) {
    printf("%d ", x);
    x += g;
  }
  printf("%d\n", x);
  return 0;
}
