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]
        B[i+1]%=M

    for b in B:
        c=B.count(b)
        count+=c-1
    print(count//2)



