#include <bits/stdc++.h>
using namespace std;
template <ostream& out = cout, class... T>
void prints(T&&...) {}
template <ostream& out = cout, class... T>
void printe(T&&...) {}
template <ostream& out = cout, class... T>
void printw(T&&...) {}
template <ostream& out = cout, class... T>
void printew(T&&...) {}
template <ostream& out = cout, class... T>
void printb(T&&...) {}
template <ostream& out = cout, class... T>
void printd(T&&...) {}
template <ostream& out = cout, class... T>
void printde(T&&...){};
template <class T>
istream& operator>>(istream& in, vector<T>& v) {
  for (auto& e : v) {
    in >> e;
  }
  return in;
}
template <char d = ' ', class T>
ostream& operator<<(ostream& out, vector<T>& v) {
  for (auto& e : v) {
    out << e << d;
  }
  return out;
}
template <class T>
bool uin(T& a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T& a, T b) {
  return a < b ? (a = b, true) : false;
}
ifstream fin("input.txt");
ofstream fout("output.txt");
const vector<int> dx{-1, 1, 0, 0};
const vector<int> dy{0, 0, 1, -1};
int gcd(int a, int b) { return a == 0 ? b : gcd(b % a, a); }
long long powq(long long a, long long n) {
  long long res = 1;
  while (n) {
    if (n & 1) {
      res *= a;
      --n;
    } else {
      a *= a;
      n >>= 1;
    }
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  int gg = k;
  for (long long i = 0; i < n; i++) {
    int x;
    cin >> x;
    gg = gcd(gg, x);
  }
  vector<int> ans;
  for (int i = 0; i < k; i += gg) ans.push_back(i);
  cout << ans.size() << '\n' << ans;
  return 0;
}
