#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, k, a[N];
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int g = a[0];
  for (int i = 1; i < n; i++) {
    g = gcd(g, a[i]);
  }
  int gk = gcd(g, k);
  if (gk == k) {
    printf("1\n");
    printf("0\n");
  } else {
    vector<int> vc;
    for (int x = 0; x < k; x += gk) {
      vc.push_back(x);
    }
    printf("%d\n", vc.size());
    for (int i = 0; i < vc.size(); i++) {
      printf("%d ", vc[i]);
    }
  }
}
