#!/mnt/c/Users/moiki/bash/env/bin/python
N,M = map(int, input().split())
A = list(map(int, input().split()))

from collections import defaultdict
d = defaultdict(int)

ans = 0
for i in range(N-1, -1, -1):
    b = defaultdict(int)

    b[ A[i] % M ]  += 1
    for dkey in d.keys():
        b[ (A[i] + dkey)%M ] +=   d[dkey] # b[A[i]] + d[dkey] 
    ans += b[0]

    d = b

#print("ans: ", ans)
# print(d)
print(ans)
    
    
