#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
const int maxn = 100010;
int n, k, g, x, ans;
int vis[maxn], a[maxn];
inline long long getint() {
  long long ret = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') ret = ret * 10 + c - '0', c = getchar();
  return ret * f;
}
inline int gcd(int a, int b) { return !b ? a : gcd(b, a % b); }
int main() {
  n = getint();
  k = getint();
  g = 0;
  for (int i = 1; i <= n; i++) a[i] = getint();
  for (int i = 1; i <= n; i++) g = gcd(g, a[i]);
  g %= k;
  x = g;
  while (!vis[x]) {
    vis[x] = 1;
    x = (x + g) % k;
    ans++;
  }
  printf("%d\n", ans);
  for (int i = 0; i < k; i++)
    if (vis[i]) printf("%d ", i);
  return 0;
}
