def nc2(n):
    return n * (n-1)//2
 
def solve(n,m,a):
    s = [0] * (n+1)
    s[0] = int(a[0]) % m
    for i in range(n):
        s[i+1] = (s[i] + int(a[i]))%m
    count = [0]*m
    for i in s:
        count[i] = count[i]+1
    res =  count[0]
    for c in count:
        res = res + nc2(c)
    return res
 
n,m = map(int,input().split())
arr = input().split()
print(solve(n,m,arr))