#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, k, a[N], x[N];
int h[N];
int f = 0;
vector<int> ans;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    a[i] %= k;
    f = gcd(a[i], f);
  }
  f = gcd(k, f);
  if (f == 0) {
    cout << "1\n0\n";
    return 0;
  }
  int cnt = 0;
  for (int i = 0; i < k; i += f) {
    ans.push_back(i);
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    if (i) cout << ' ';
    cout << ans[i];
  }
  cout << endl;
  return 0;
}
