#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}
int main() {
  int n, k;
  cin >> n >> k;
  int a[100000];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] %= k;
    if (a[i] == 0) a[i] += k;
  }
  int r = k;
  for (int i = 0; i < n; i++) r = gcd(r, a[i]);
  cout << k / r << endl;
  for (int i = 0; i < k; i += r) cout << i << " ";
  return 0;
}
