# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
# import functools
# import itertools
# import math
mod=(10**9+7)**2
ferumaC=300000
fac=[0 for i in range(ferumaC)]
fac[0]=1
ifac=[0 for i in range(ferumaC)]
ifac[0]=1
def mpow(x,n):
    num=1
    while n > 0:
        if n&1:
            num=num*x%mod
        x=x*x%mod
        n=n>>1
    return(num)
for i in range(0,ferumaC-1):
    fac[i+1]=(fac[i]*(i+1))%mod
    ifac[i+1]=ifac[i]*mpow(i+1,mod-2)%mod
def comb(a,b):
    if a==0 and b==0:return(1)
    if a<b or a<0:return(0)
    tmp=ifac[a-b]*ifac[b]%mod
    return(tmp*fac[a]%mod)
N,M=map(int,input().split())
A=list(map(int,input().split()))
#A=[i%M for i in A]
data=[0 for i in range(N)]
data[0]=A[0]%M
for i in range(1,N):
    data[i]=(data[i-1]+A[i])%M
data.append(0)
data=Counter(data)
print(sum([comb(data[i],2) for i in data if data[i]>=2]))
