#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")
using namespace std;
mt19937 rnd(time(0));
const long long maxn = 3e5 + 7, mod = 1e9 + 7, inf = 1e18;
const long double eps = 1e-9, pi = acos(-1);
long long n, k;
long long cnt[maxn];
long long have[maxn];
long long resh[maxn];
long long gcd(long long a, long long b) {
  while (b) {
    long long c = a % b;
    a = b;
    b = c;
  }
  return a;
}
void solve() {
  cin >> n >> k;
  long long k1 = k;
  for (long long i = 0; i < n; ++i) {
    cin >> cnt[i];
    cnt[i] %= k;
    k1 = gcd(k1, cnt[i]);
  }
  cout << k / k1 << '\n';
  for (long long i = 0; i < k; i += k1) cout << i << " ";
}
signed main() {
  srand(time(0));
  cout.precision(10);
  cout << fixed;
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}
