#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
void Solve() {
  int n, k;
  cin >> n >> k;
  int d = k;
  for (signed i = 0; i < (n); i++) {
    int a;
    cin >> a;
    if (a %= k) d = gcd(d, a);
  }
  int sz = k / d;
  cout << sz << '\n';
  for (signed i = 0; i < (sz); i++) cout << i * d << ' ';
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  Solve();
  return 0;
}
