#include <bits/stdc++.h>
using namespace std;
const int prime = 999983;
const int INF = 0x7FFFFFFF;
const long long INFF = 0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const long long mod = 1e9 + 7;
long long qpow(long long a, long long b) {
  long long s = 1;
  while (b > 0) {
    if (b & 1) s = s * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return s;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int dr[2][4] = {1, -1, 0, 0, 0, 0, -1, 1};
const int maxn = 1e5 + 10;
bool a[maxn];
bool sign[maxn];
int main(void) {
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  int tmp;
  for (int i = 0; i < n; ++i) {
    cin >> tmp;
    a[tmp % k] = 1;
  }
  bool Have = false;
  int d;
  for (int i = 0; i < k; ++i)
    if (a[i]) {
      if (!Have)
        d = i, Have = true;
      else
        d = gcd(d, i);
    }
  int j = d;
  for (int l = 0; l < k + 1; ++l, j += d, j %= k) {
    a[j] = 1;
  }
  int tot = 0;
  for (int i = 0; i < k; ++i)
    if (a[i]) tot++;
  cout << tot << endl;
  for (int i = 0; i < k; ++i)
    if (a[i]) cout << i << " ";
  return 0;
}
