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