def nc2(n):
    return n * (n-1)//2

def solve(n,m,a):
    s = [0]    
    for i in a:
        s.append(s[-1]+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 = map(int,input().split())

print(solve(n,m,a))