import math
from fractions import gcd
from functools import reduce
n, m = map(int, input().split())
array = list(map(int, input().split()))

length = len(array)

g = reduce(gcd, array+ [m])

array = [a // g for a in array]
m //= g

how_many = []
for i in range(length):
    mod_list ={}
    mod = array[i] % m
    if i != 0:
        for k in mod_list_old.keys():
            mod_list[(k + mod) % m] = mod_list_old[k]
    mod_list[mod] = mod_list.get(mod, 0) + 1
    how_many.append(mod_list.get(0, 0))
    mod_list_old = {}
    for k, v in mod_list.items():
        mod_list_old[k] = mod_list[k]
print(sum(list(how_many)))

