#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const double EPS = 1e-9;
const long long INF = 1e18 + 2007;
const double PI = 3.1415926535897932384626433832795;
const long long N = 200005;
long long gcd(long long a, long long b) { return a ? gcd(b % a, a) : b; }
signed main() {
  ios_base::sync_with_stdio(0);
  long long n, k;
  cin >> n >> k;
  long long g = 0;
  for (long long i = 0; i < n; i++) {
    long long a;
    cin >> a;
    g = gcd(g, a);
  }
  set<long long> ans;
  for (long long i = 0; i < k; i++) {
    ans.insert((g * i) % k);
  }
  cout << ans.size() << endl;
  for (auto x : ans) {
    cout << x << ' ';
  }
  return 0;
}
