#include <bits/stdc++.h>
using namespace std;
map<int, bool> mb;
vector<int> v;
int gcd(int a, int b) {
  if (a < b) swap(a, b);
  if (b == 0)
    return a;
  else
    return (b, a % b);
}
int main() {
  int n, m, g;
  long long i, s;
  cin >> n >> m;
  g = 0;
  for (i = 0; i < n; ++i) {
    cin >> s;
    g = gcd(g, s);
  }
  for (i = 0, s = 0; i < m; i++, s += g) {
    if (mb[s % m] == 0) {
      mb[s % m] = 1;
      v.push_back(s % m);
    }
  }
  sort(v.begin(), v.end());
  cout << v.size() << endl;
  for (i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
  return 0;
}
