#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INFF = 0x3f3f3f3f3f3f3f3fll;
const long long M = 1e9 + 7;
const long long maxn = 1e6 + 7;
const double pi = acos(-1.0);
const double eps = 0.0000000001;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
template <typename T>
inline void pr2(T x, int k = 64) {
  long long i;
  for (i = 0; i < k; i++) fprintf(stderr, "%d", (x >> i) & 1);
  putchar(' ');
}
template <typename T>
inline void add_(T &A, int B) {
  A += B;
  (A >= M) && (A -= M);
}
template <typename T>
inline void mul_(T &A, long long B) {
  (A *= B) %= M;
}
template <typename T>
inline void mod_(T &A, long long B = M) {
  A %= M;
}
template <typename T>
inline void max_(T &A, T B) {
  (A < B) && (A = B);
}
template <typename T>
inline void min_(T &A, T B) {
  (A > B) && (A = B);
}
template <typename T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
template <typename T>
inline T powMM(T a, T b) {
  T ret = 1;
  for (; b; b >>= 1ll, a = (long long)a * a % M)
    if (b & 1) ret = (long long)ret * a % M;
  return ret;
}
int n, m, q;
char str[maxn];
int TaskA();
void Task_one() { TaskA(); }
void Task_T() {
  int T;
  scanf("%d", &T);
  while (T--) TaskA();
}
void Task_more_n() {
  while (~scanf("%d", &n)) TaskA();
}
void Task_more_n_m() {
  while (~scanf("%d%d", &n, &m)) TaskA();
}
void Task_more_n_m_q() {
  while (~scanf("%d%d%d", &n, &m, &q)) TaskA();
}
void Task_more_string() {
  while (~scanf("%s", str)) TaskA();
}
int A[maxn];
int TaskA() {
  int i, t, k;
  scanf("%d%d", &n, &k);
  t = k;
  for (i = 1; i <= n; i++) scanf("%d", &A[i]), t = gcd(t, A[i]);
  printf("%d\n", k / t);
  for (i = 0; i < k / t; i++) printf("%d ", i * t);
  return 0;
}
void initialize() {}
int main() {
  int startTime = clock();
  initialize();
  fprintf(stderr, "/--- initializeTime: %ld milliseconds ---/\n",
          clock() - startTime);
  Task_one();
}
