#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int i, j;
  int cnt = k;
  for (i = 0; i < n; i++) {
    int xxx;
    scanf("%d", &xxx);
    cnt = gcd(cnt, xxx % k);
  }
  if (cnt != 0) printf("%d\n", k / cnt);
  for (i = 0; i < k; i = i + cnt) {
    if (i != 0) printf(" ");
    printf("%d", i);
  }
  printf("\n");
  return 0;
}
