#include <bits/stdc++.h>
using namespace std;
const long long MOD = (long long)1e9 + 7;
const int inf = (int)1e9 + 7;
const double eps = 1e-7;
const double pi = 3.14159265359;
const int N = 1e5;
int n, k, a[N];
int nod(int a, int b) {
  if (a < b) swap(a, b);
  while (b) {
    int p = a;
    a = b;
    b = p % b;
  }
  return a;
}
int main() {
  scanf("%d%d", &n, &k);
  int cur;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    a[i] %= k;
    cur = (i ? nod(a[i], cur) : nod(a[i], k));
  }
  vector<int> ans;
  for (int i = 0; i < k; ++i) {
    if (i % cur == 0) ans.push_back(i);
  }
  printf("%d\n", ans.size());
  for (auto elem : ans) printf("%d ", elem);
  return 0;
}
