#include <bits/stdc++.h>
using namespace std;
set<long long> s;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long n, k, u;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  cin >> u;
  long long g = u;
  for (int i = 1, ThxDem = n; i < ThxDem; ++i) {
    int u;
    cin >> u;
    g = gcd(g, u);
  }
  for (int i = 1, ThxDem = k + k; i < ThxDem; ++i) s.insert((i * g) % k);
  cout << ((int)(s).size()) << "\n";
  for (int v : s) cout << v << " ";
  cout << "\n";
}
