#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[100050];
bool vis[100050];
map<int, int> mo;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  scanf("%d%d", &n, &k);
  mo.clear();
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    a[i] %= k;
  }
  int tmp = a[1];
  for (int i = 2; i <= n; i++)
    if (a[i] != 0) tmp = gcd(tmp, a[i]);
  if (tmp == 0)
    vis[0] = 0;
  else
    for (int i = 0; i < k; i += tmp) vis[i] = 1;
  if (tmp != 1) {
    mo[tmp] = 1;
    for (int i = 1; i <= n; i++) {
      if (a[i] == 0) {
        vis[0] = 1;
        continue;
      }
      tmp = gcd(a[i], k);
      if (!mo[tmp]) {
        mo[tmp] = 1;
        for (int j = 0; j < k; j += tmp) vis[j] = 1;
      }
      if (tmp == 1) break;
    }
  }
  int ans = 0;
  for (int i = 0; i < k; i++) {
    if (vis[i]) ans++;
  }
  printf("%d\n", ans);
  int cnt = 1;
  for (int i = 0; i < k; i++) {
    if (vis[i]) {
      printf("%d", i);
      if (cnt == ans)
        printf("\n");
      else
        printf(" ");
      cnt++;
    }
  }
  return 0;
}
