#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long n, k, ag, tax[100000 + 10];
void clean() { memset(tax, 0, sizeof tax), tax[0] = 1; }
int solve() {
  clean();
  cin >> n >> k;
  cin >> ag;
  for (long long a, i = 2; i <= n; i++) cin >> a, ag = gcd(ag, a % k);
  tax[ag % k] = 1;
  for (long long i = 2 * ag; i % k != ag % k; i += ag) tax[i % k] = 1;
  long long ans = 0;
  for (long long i = 0; i < k; i++)
    if (tax[i]) ans++;
  cout << ans << endl;
  for (long long i = 0; i < k; i++)
    if (tax[i]) cout << i << " ";
  return 0;
}
int main() {
  solve();
  return 0;
}
