#include <bits/stdc++.h>
using namespace std;
int n, k;
bool a[100001];
int gcd(int a, int b) { return a % b ? gcd(b, a % b) : b; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  set<int> s;
  for (int i = 0, t; i < n; ++i) {
    cin >> t;
    t %= k;
    s.insert(t);
  }
  int GCD = k;
  for (auto i : s) {
    if (!i) continue;
    GCD = gcd(GCD, i);
  }
  for (int j = 1; j <= k / GCD; ++j) a[(GCD * j) % k] = 1;
  int ans = 0;
  for (int i = 0; i < k; ++i) {
    ans += a[i];
  }
  cout << ans << '\n';
  for (int i = 0; i < k; ++i) {
    if (a[i]) cout << i << " ";
  }
  return 0;
}
