#include <bits/stdc++.h>
int n, k, x, a[100010];
int gcd(int a, int b) { return a % b == 0 ? b : gcd(b, a % b); }
int main() {
  scanf("%d%d", &n, &k);
  scanf("%d", &x);
  for (int i = 2; i <= n; i++) {
    int y;
    scanf("%d", &y);
    x = gcd(x, y);
  }
  x = gcd(x, k);
  for (int i = 1; i <= k; i++) a[1LL * i * x % k] = 1;
  int t = 0;
  for (int i = 0; i < k; i++)
    if (a[i]) t++;
  printf("%d\n", t);
  for (int i = 0; i < k; i++)
    if (a[i]) printf("%d ", i);
  return 0;
}
