#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int main() {
  int n, k;
  while (~scanf("%d%d", &n, &k)) {
    int b;
    int x;
    scanf("%d", &b);
    for (int i = 1; i < n; i++) {
      scanf("%d", &x);
      b = gcd(x, b);
    }
    set<long long> s;
    long long i = 0, j = 0;
    while (j < k) {
      s.insert(i % k);
      i = i + b;
      j++;
    }
    cout << s.size() << endl;
    set<long long>::iterator it;
    for (it = s.begin(); it != s.end(); it++) {
      if (it == s.begin())
        cout << *it;
      else
        cout << " " << *it;
    }
    cout << endl;
  }
}
