import sys
input=sys.stdin.readline

if __name__ == '__main__':
    N,M=list(map(int,input().split()))
    A=list(map(int,input().split()))
    B=[0]*(N+1)
    count=0
    for i in range(N):
        B[i+1]=B[i]+A[i]
        
    mods={}
    for b in B:
        c=b%M
        if c in mods.keys():
            mods[c]+=1
        else:
            mods[c]=1
    for v in mods.values():
        count+=(v*(v-1))//2
    print(count)
