#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
const int ddx[8] = {0, 0, 1, 1, 1, -1, -1, -1},
          ddy[8] = {1, -1, 1, 0, -1, 1, 0, -1};
const int INF = 0x7f7f7f7f;
const long long INF_LL = 0x7f7f7f7f7f7f7f7f;
long long POW(long long a, long long b, long long MMM) {
  long long ret = 1;
  for (; b; b >>= 1, a = (a * a) % MMM)
    if (b & 1) ret = (ret * a) % MMM;
  return ret;
}
long long GCD(long long a, long long b) { return b ? GCD(b, a % b) : a; }
long long LCM(long long a, long long b) {
  if (a == 0 || b == 0) return a + b;
  return a / GCD(a, b) * b;
}
long long INV(long long a, long long m) {
  long long m0 = m, y = 0, x = 1;
  if (m == 1) return 0;
  while (a > 1) {
    long long q = a / m;
    long long t = m;
    m = a % m, a = t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0) x += m0;
  return x;
}
pair<long long, long long> EXGCD(long long a, long long b) {
  if (b == 0) return {1, 0};
  auto t = EXGCD(b, a % b);
  return {t.second, t.first - t.second * (a / b)};
}
bool OOB(long long x, long long y, long long N, long long M) {
  return 0 > x || x >= N || 0 > y || y >= M;
}
int N, K;
int A[100005];
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    A[i] %= K;
  }
  int totg = K;
  for (int i = 0; i < N; i++) {
    if (A[i] == 0) continue;
    int g = GCD(K, A[i]);
    totg = GCD(totg, g);
    if (totg == 1) break;
  }
  cout << (K / totg) << '\n';
  for (int i = 0; i < K; i += totg) {
    cout << (i) << ' ';
  }
}
