#include <bits/stdc++.h>
using namespace std;
int n, k, g;
int a[100010];
int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
bool used[100010];
int main() {
  scanf("%d%d", &n, &k);
  g = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    a[i] %= k;
    g = gcd(g, a[i]);
    g = gcd(g, k - a[i]);
  }
  int cnt = 0;
  for (int i = 0; i < k; i += g) {
    if (used[i] == 1) break;
    used[i] = 1;
    cnt++;
  }
  printf("%d\n", cnt);
  for (int i = 0; i < k; i++)
    if (used[i] == 1) printf("%d ", i);
}
