import sys,math,itertools
input=sys.stdin.readline


if __name__ == '__main__':
    N,M=list(map(int,input().split()))
    A=list(map(int,input().split()))
    B=[0]+A
    B=list(itertools.accumulate(B))
    count=0
    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)