#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:167772160")
using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
using dbl = double;
const int INF = (int)1e9 + 10;
const ll LINF = ll(2e18) + 10;
const double PI = acosl(-1);
const double eps = 1e-8;
const int N = 1e5 + 10;
int n, k;
int a[N];
int gcd(int x, int y) {
  while (y) {
    x %= y;
    swap(x, y);
  }
  return x;
}
void solve() {
  scanf("%d%d", &n, &k);
  int g = k;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    a[i] %= k;
    g = gcd(g, a[i]);
  }
  vector<int> res;
  for (int i = 0; i < k; ++i)
    if (i % g == 0) res.push_back(i);
  printf("%d\n", int(res.size()));
  for (auto x : res) printf("%d ", x);
  puts("");
}
int main() {
  solve();
  (void)0;
}
