#include <bits/stdc++.h>
using namespace std;
int N, K, tmp;
int gcd(int a, int b) { return a % b == 0 ? b : gcd(b, a % b); }
int main() {
  cin >> N >> K;
  tmp = K;
  for (int i = 1; i < N + 1; i++) {
    int x;
    cin >> x;
    tmp = gcd(x, tmp);
  }
  cout << (K - 1) / (tmp) + 1 << endl;
  for (int i = 0; i < K; i = i + tmp) {
    cout << i << ' ';
  }
}
