import sys
input=sys.stdin.readline

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

if __name__ == '__main__':
    N,M=list(map(int,input().split()))
    A=list(map(int,input().split()))
    B=[0]*(N+1)
    count=0
    mods=[]
    for i in range(N):
        B[i+1]=B[i]+A[i]
        B[i+1]%=M

    mods={}

    for b in B:
        c=B.count(b)
        if b in mods.keys():
            continue
        else:
            mods[b]=c
    for v in mods.values():
        count+=nC2(v)
    print(count)



