#include <bits/stdc++.h>
using namespace std;
int n, k;
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
int main() {
  scanf("%d%d", &n, &k);
  int G = k;
  for (int i = (int)(1); i <= (int)(n); i++) {
    int x;
    scanf("%d", &x);
    G = gcd(G, x);
  }
  printf("%d\n", k / G);
  for (int j = (int)(0); j <= (int)(k / G - 1); j++) printf("%d ", j * G);
}
