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
mod_list =[0]*m

how_many = []
for i in range(length):
    mod = array[i] % m
    if i != 0:
        for j in range(m):
            mod_list[(j + mod) % m] = mod_list_old[j]
    mod_list[mod] += 1
    how_many.append(mod_list[0])
    mod_list_old = mod_list[:]
print(sum(how_many))

