class BigCombination(object):
    __slots__ = ["mod", "factorial", "inverse"]
 
    def __init__(self, mod: int = 10**9+7, max_n: int = 10**6):
        fac, inv = [1], []
        fac_append, inv_append = fac.append, inv.append
 
        for i in range(1, max_n+1):
            fac_append(fac[-1] * i % mod)
 
        inv_append(pow(fac[-1], mod-2, mod))
 
        for i in range(max_n, 0, -1):
            inv_append(inv[-1] * i % mod)
 
        self.mod, self.factorial, self.inverse = mod, fac, inv[::-1]
 
    def get_combination(self, n, r):
        return self.factorial[n] * self.inverse[r] * self.inverse[n-r] % self.mod
 
    def get_permutation(self, n, r):
        return self.factorial[n] * self.inverse[n-r] % self.mod
 
 
import math
Big = BigCombination()

N, L = map(int, input().split())
x = list(map(int, input().split()))
s=[0]*N
si=0
s[0] =x[0]%L
if x[0]%L==0:si+=1
dic ={s[0]}
for i in range(1,N):
    s[i] = (s[i-1]+x[i])%L
    if s[i]%L==0:si+=1
    if s[i] not in dic:
        dic.add(s[i])
#print(s,dic)
for i in dic:
    #print(i)
    if s.count(i)>1:si+=Big.get_combination(s.count(i), 2)
    #print(si)
print(si)
