#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const int N = (int)2e5 + 1;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const long long linf = (long long)1e18 + 7;
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
using namespace std;
int n, k;
int a[N];
int gcd(int x, int y) {
  while (y) {
    x %= y;
    swap(x, y);
  }
  return x + y;
}
int main() {
  ios_base ::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> k;
  int g = k;
  for (int i = (0); i <= (n - 1); i++) {
    cin >> a[i];
    a[i] %= k;
    g = gcd(a[i], g);
  }
  vector<int> ans;
  for (int i = (0); i <= (k - 1); i++) {
    if (i % g == 0) ans.push_back(i % k);
  }
  cout << (int)ans.size() << '\n';
  for (auto it : ans) cout << it << ' ';
  exit(0);
}
