#include <bits/stdc++.h>
using namespace std;
int n, k;
const int maxn = 1e5 + 5;
long long int a;
bool vis[maxn];
vector<int> out;
long long int gcd(long long int x, long long int y) {
  if (x < y) swap(x, y);
  if (y == 0) return x;
  if (x % y == 0) return y;
  return gcd(y, x % y);
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> k;
  long long int g = 0;
  for (int i = 0; i < n; i++) {
    cin >> a;
    a = a % k;
    g = gcd(g, a);
  }
  for (int i = 0; i < k; i++) vis[i * g % k] = 1;
  for (int i = 0; i < k; i++)
    if (vis[i]) out.push_back(i);
  cout << out.size() << endl;
  for (int i = 0; i < out.size(); i++) cout << out[i] << ' ';
  cout << endl;
  return 0;
}
