#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e5 + 5;
long long n, k, a, ans = -1, num;
bool Mark[MAXN];
vector<long long> v;
int gcd(int a, int b) { return (!b ? a : gcd(b, a % b)); }
int main() {
  scanf("%lld%lld", &n, &k);
  for (long long i = 0; i < n; i++) {
    scanf("%lld", &a);
    if (ans == -1)
      ans = a % k;
    else
      ans = gcd(ans, a % k);
  }
  for (int i = 0;; i++) {
    if (Mark[ans * i % k]) break;
    num++;
    Mark[ans * i % k] = 1;
  }
  printf("%lld\n", num);
  for (int i = 0; i < k; i++)
    if (Mark[i]) cout << i << " ";
  return 0;
}
