#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000000000000000000LL;
const long long NMAX = 1e6 + 4;
const long long mod = 1e9 + 7;
const double eps = 1e-10;
const double PI = acos(-1);
long long gcd(long long a, long long b) { return a == 0 ? b : gcd(b % a, a); }
signed main() {
  ios::sync_with_stdio(false);
  long long n, k;
  cin >> n >> k;
  long long g = k;
  for (long long i = (0); i < (n); i++) {
    long long a;
    cin >> a;
    g = gcd(g, a);
  }
  cout << k / g << endl;
  for (long long i = 0; i < k; i += g) cout << i << " ";
  cout << endl;
}
