#include <bits/stdc++.h>
using namespace std;
int n, k;
bool used[100100];
int gcd(int a, int b) {
  if (!b) return a;
  return gcd(b, a % b);
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> k;
  int g = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    g = gcd(g, x);
  }
  for (int i = 0, x = 0; i < k; i++, x += g) {
    x %= k;
    used[x] = true;
  }
  vector<int> ans;
  for (int i = 0; i < k; i++) {
    if (used[i]) {
      ans.push_back(i);
    }
  }
  cout << ans.size() << endl;
  for (int x : ans) {
    cout << x << " ";
  }
  cout << endl;
  return 0;
}
