def inpl(): return [int(i) for i in input().split()]

def solve(n,S):
    Ctr = set([])
    for i in range(n+1):
        Ctr = Ctr | set([S[i]])
    Ans = {}
    for i in range(n+1):
        Ans[S[i]] = 0
    for i in range(n+1):
        Ans[S[i]] += 1
    
    ans = 0
    for i in Ctr:
        ans += Ans[i] * (Ans[i] - 1) // 2
    return(ans)

N,M = inpl()
H = inpl()

SumH = [0]
for i in range(N):
    SumH.append((SumH[-1] + H[i]) % M)

print(solve(N,SumH))