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