#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int a[maxn];
bool vis[maxn];
set<int> st;
bool fg = 0;
int n, k, d;
int gcd(int a, int b) { return (b == 0 ? a : gcd(b, a % b)); }
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> k;
  int d = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    d = gcd(a[i], d);
  }
  st.insert(0);
  for (long long sum = 0, i = 0; i < k; i++, sum += d) {
    st.insert(sum % k);
  }
  cout << st.size() << endl;
  for (auto a : st) cout << a << " ";
  cout << endl;
  return 0;
}
