#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
int main() {
  int n, k;
  cin >> n >> k;
  long long int arr[n];
  int j;
  cin >> arr[0];
  long long int val = arr[0];
  for (j = 1; j < n; j++) {
    cin >> arr[j];
    val = gcd(val, arr[j]);
  }
  set<long long int> s;
  for (j = 1; j <= k; j++) s.insert((val % k * j % k) % k);
  cout << s.size() << endl;
  for (set<long long int>::iterator iter = s.begin(); iter != s.end(); iter++) {
    cout << *iter << " ";
  }
  cout << endl;
}
