#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
bool vis[100100];
set<int> s;
int n, a, k, g;
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a);
    g = gcd(g, a % k);
  }
  for (int i = g; !vis[i]; i += g, i = i >= k ? i - k : i)
    s.insert(i), vis[i] = 1;
  cout << s.size() << endl;
  for (int i : s) cout << i << " ";
}
