#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream &operator<<(ostream &os, const pair<T, T> &p) {
  return os << "(" << p.first << "," << p.second << ")";
}
template <class T>
ostream &operator<<(ostream &os, const pair<const T, T> &p) {
  return os << "(" << p.first << "," << p.second << ")";
}
template <class T>
ostream &operator<<(ostream &os, const array<T, 3> &p) {
  return os << "(" << p[0] << "," << p[1] << "," << p[2] << ")";
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &p) {
  os << "{ ";
  for (auto x : p) os << x << ' ';
  return os << '}';
}
const double EPS = 1e-9;
const double PI = acos(-1);
const int INF = 0x3f3f3f3f;
const long long int LINF = 0x3f3f3f3f3f3f3f3f;
const int SZ = 1e3 + 20;
const long long int mod = 1e9 + 7;
int gcd(int x, int y) { return y == 0 ? x : gcd(y, x % y); }
int main() {
  int n, k;
  scanf(" %d %d", &n, &k);
  int g = k;
  while (n--) {
    int x;
    scanf(" %d", &x);
    x = x % k;
    if (x) g = gcd(g, x % k);
  }
  vector<int> res;
  for (int i = 0; i < k; i += g) res.push_back(i);
  printf("%d\n", res.size());
  for (auto x : res) printf("%d ", x);
  cout << "\n";
  return 0;
}
