#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;
int i, j, k, l, n, m, sum, maxx, minn, ans, x, y, flag, cc, a[100001], mm;
int gcd(int a, int b) { return !b ? a : gcd(b, a % b); }
int main() {
  cin >> n >> m;
  cin >> a[0];
  mm = a[0];
  for (i = 1; i < n; i++) {
    scanf("%d", &a[i]);
    mm = gcd(mm, a[i]);
  }
  mm = gcd(mm, m);
  cout << m / mm << endl;
  for (i = 0;; i++) {
    if (i * mm < m)
      cout << i * mm << " ";
    else {
      cout << endl;
      break;
    }
  }
  return 0;
}
