#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
const int MX = 123456;
const int mod = (int)1e9 + 7;
const int base = 1023456789;
const unsigned long long BS1 = 10000019ULL;
const int INF = (1 << 29);
template <class T>
inline void fastScan(T &x) {
  register char c = getchar();
  int neg = 0;
  x = 0;
  for (; (c < 48 || c > 57) && (c != '-'); c = getchar())
    ;
  if (c == '-') {
    neg = 1;
    c = getchar();
  }
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  if (neg) x = -x;
}
int n, k;
int inp[N];
int seen[N];
int GCD(int a, int b) {
  if (b == 0) return a;
  return GCD(b, a % b);
}
int main() {
  fastScan(n);
  fastScan(k);
  for (int i = 0; i < n; i++) {
    fastScan(inp[i]);
  }
  int gcd = 0;
  for (int i = 0; i < n; i++) {
    gcd = GCD(gcd, inp[i]);
  }
  for (int i = 0, j = 0; i < k; i++) {
    seen[j] = 1;
    j += gcd;
    j %= k;
  }
  int ans = 0;
  for (int i = 0; i < k; i++) {
    if (seen[i]) {
      ans++;
    }
  }
  printf("%d\n", ans);
  for (int i = 0; i < k; i++) {
    if (seen[i]) {
      printf("%d ", i);
    }
  }
  puts("");
}
