#include <bits/stdc++.h>
using namespace std;
inline long long mod(long long n, long long m) {
  long long ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}
long long gcd(long long a, long long b) {
  return (b == 0LL ? a : gcd(b, a % b));
}
long long exp(long long a, long long b, long long m) {
  if (b == 0LL) return 1LL;
  if (b == 1LL) return mod(a, m);
  long long k = mod(exp(a, b / 2, m), m);
  if (b & 1LL) {
    return mod(a * mod(k * k, m), m);
  } else
    return mod(k * k, m);
}
void brute() {
  for (int k = 2; k <= 15; k++) {
    cout << "K = " << k << "\n";
    for (int x = 1; x < k; x++) {
      set<int> S;
      for (int j = 1; j < k; j++) S.insert((x * j) % k);
      cout << "X = " << x << ", has: ";
      for (int y : S) cout << y << " ";
      cout << "\n";
    }
  }
}
const int N = 400100;
int a[N];
bool dp[N];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, k;
  cin >> n >> k;
  set<int> S;
  int g = -1;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (g == -1)
      g = a[i];
    else
      g = gcd(g, a[i]);
  }
  g = gcd(g, k);
  S.insert(g);
  dp[0] = 1;
  for (int x : S) {
    for (int i = x; i < 4 * k; i++) {
      dp[i] |= dp[i - x];
    }
  }
  vector<int> ans;
  for (int i = 0; i < k; i++)
    if (dp[i] or dp[i + k]) ans.push_back(i);
  cout << (int)ans.size() << "\n";
  for (int x : ans) cout << x << " ";
  cout << "\n";
}
