#include <bits/stdc++.h>
using namespace std;
const int N = 100007;
int n, k, g;
bool have[N];
vector<int> ans;
int gcd(int a, int b) {
  int r;
  while (b) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int i, x;
  scanf("%d %d", &n, &k);
  g = k;
  for (i = 1; i <= n; i++) {
    scanf("%d", &x);
    x %= k;
    g = gcd(g, x);
  }
  for (i = g;; i += g, i %= k) {
    if (have[i]) break;
    have[i] = true;
  }
  for (i = 0; i < k; i++) {
    if (have[i]) {
      ans.push_back(i);
    }
  }
  printf("%d\n", (int)(ans.size()));
  for (i = 0; i < (int)(ans.size()); i++) {
    if (i > 0) printf(" ");
    printf("%d", ans[i]);
  }
  printf("\n");
  return 0;
}
