#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 1e18;
template <typename T>
void read(T &x) {
  x = 0;
  int s = 1, c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') s = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
  x *= s;
}
template <typename T>
void write(T x) {
  if (x < 0) x = -x, putchar('-');
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
void writeln(T x) {
  write(x);
  puts("");
}
const int maxn = 1e5 + 5;
int n, k;
int a[maxn];
int __gcd(int a, int b) { return b ? __gcd(b, a % b) : a; }
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] %= k;
  }
  int gcd = __gcd(a[1], k);
  for (int i = 2; i <= n; i++) {
    int g = __gcd(a[i], k);
    gcd = __gcd(gcd, g);
  }
  if (gcd) {
    cout << k / gcd << endl;
    for (int i = 1; i <= k / gcd; i++) {
      cout << (i - 1) * gcd << " ";
    }
  } else {
    cout << 1 << endl << 0 << endl;
  }
}
