#include <bits/stdc++.h>
using namespace std;
long long int minn(long long int a, long long int b) { return a < b ? a : b; }
long long int maxx(long long int a, long long int b) { return a > b ? a : b; }
long long int cill(long long int a, long long int b) {
  if (a % b == 0) return a / b;
  return a / b + 1;
}
long long int abss(long long int a) {
  if (a >= 0)
    return a;
  else
    return -1 * (a);
}
long double get_angle(pair<int, int> a, pair<int, int> b, pair<int, int> c) {
  int x1 = a.first;
  int y1 = a.second;
  int x2 = b.first;
  int y2 = b.second;
  int x3 = c.first;
  int y3 = c.second;
  long double len1 = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  long double len2 = sqrt((x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2));
  long double val =
      ((x1 - x2) * (x3 - x2) + (y1 - y2) * (y3 - y2)) / (len1 * len2);
  return acos(val);
}
long double find_point_dis(pair<int, int> point1, pair<int, int> point2) {
  long double temp_ans;
  temp_ans = ((point1.first - point2.first) * (point1.first - point2.first));
  temp_ans +=
      ((point1.second - point2.second) * (point1.second - point2.second));
  return sqrt(temp_ans);
}
int check_sidde(pair<int, int> p1, pair<int, int> p2, pair<int, int> p3) {
  int x1 = p1.first;
  int y1 = p1.second;
  int x2 = p2.first;
  int y2 = p2.second;
  int x3 = p3.first;
  int y3 = p3.second;
  long long int ans = (x3 - x1) * (y1 - y2) - (y3 - y1) * (x1 - x2);
  if (ans >= 0)
    return 1;
  else
    return -1;
}
long long int cnt_div(long long int n, long long int k) {
  long long int cnt = 0;
  while (n % k == 0) {
    cnt++;
    n /= k;
  }
  return cnt;
}
long long int gcd(long long int a, long long int b) {
  if (a % b == 0) return b;
  return gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  long long int g = gcd(a, b);
  return (a * b) / g;
}
bool primechk[10000];
vector<int> primes;
void seive() {
  for (long long int i = 2; i * i < 10000; i++)
    if (primechk[i] == false)
      for (long long int j = i * i; j < 10000; j += i) primechk[j] = true;
  for (int i = 2; i < 10000; i++)
    if (primechk[i] == false) primes.push_back(i);
}
struct node {
  bool flag;
  int counter;
  node* cur[26];
  node() {
    counter = 0;
    flag = false;
    for (int i = 0; i < 26; i++) cur[i] = NULL;
  }
};
class TRIE {
  void insert(node* cur_node, string name) {
    for (int i = 0; i < name.size(); i++) {
      if (cur_node->cur[name[i] - 'a'] == NULL)
        cur_node->cur[name[i] - 'a'] = new node();
      cur_node = cur_node->cur[name[i] - 'a'];
    }
    cur_node->flag = 1;
  }
  bool search(node* cur_node, string s) {
    for (int i = 0; i < s.size(); i++)
      if (cur_node->cur[s[i] - 'a'] == NULL)
        return false;
      else
        cur_node = cur_node->cur[s[i] - 'a'];
    return cur_node->flag;
  }
};
vector<int> adj[10000 + 1];
vector<int> cost[10000 + 1];
long long int level[10000 + 1];
int sparse_table[10000 + 1][20];
int parent[10000 + 1];
int n, m;
void dfs(int node, int par) {
  parent[node] = par;
  for (int i = 0; i < adj[node].size(); i++)
    if (adj[node][i] != parent[node]) {
      level[adj[node][i]] = level[node] + cost[node][i];
      dfs(adj[node][i], node);
    }
}
void create_sparse_table() {
  for (int j = 1; j <= log2(n); j++) {
    for (int i = 1; i <= n; i++) {
      int par = sparse_table[i][j - 1];
      if (par != -1) sparse_table[i][j] = sparse_table[par][j - 1];
    }
  }
}
int lca(int a, int b) {
  if (level[b] < level[a]) swap(a, b);
  int d = level[b] - level[a];
  while (d > 0) {
    int jump = log2(d);
    b = sparse_table[b][jump];
    d -= (1 << jump);
  }
  if (a == b) return a;
  for (int i = log2(n); i >= 0; i--)
    if (sparse_table[a][i] != -1 && sparse_table[a][i] != sparse_table[b][i]) {
      a = sparse_table[a][i];
      b = sparse_table[b][i];
    }
  return parent[a];
}
void preprocess() {
  for (int i = 0; i <= n; i++) {
    parent[i] = -1;
    adj[i].clear();
    cost[i].clear();
    level[i] = 0;
    for (int j = 0; j <= log2(n); j++) sparse_table[i][j] = -1;
  }
}
void solve(int t) {
  int n, k;
  cin >> n >> k;
  vector<long long int> v;
  for (int i = 0; i < n; i++) {
    long long int x;
    cin >> x;
    v.push_back(x);
  }
  long long int g = v[0];
  for (int i = 1; i < n; i++) g = gcd(g, v[i]);
  set<int> s;
  for (int i = 0; i < k; i++) {
    long long int anss = (i * g) % k;
    s.insert(anss);
  }
  cout << s.size() << endl;
  for (auto x : s) cout << x << " ";
  cout << endl;
}
int main() { solve(1); }
