#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return a == 0 ? b : gcd(b % a, a); }
int main() {
  int n, k, x;
  scanf("%d%d", &n, &k);
  int tmp = k;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    tmp = gcd(x % k, tmp);
  }
  printf("%d\n", k / tmp);
  for (int i = 0; i < k / tmp; i++)
    printf("%d%c", i * tmp, i == k / tmp - 1 ? '\n' : ' ');
  return 0;
}
