N, M =map(int, input().split())
A = list(map(int, input().split()))

from collections import Counter

P = 10**9+7

"""aのp乗を計算"""
def modpow(a, p):
    if p==0:
        return 1
    else:
        if p%2==0:
            return (modpow(a, p//2)**2)%P
        else:
            return (a*modpow(a, p-1))%P

"""nCkを計算"""
def comb(n, k):
    if n<k:
        return 0
    elif n==k or k==0:
        return 1
    else:
        mul = 1
        div = 1
        for i in range(1, min(k, n-k)+1):
            mul *= n-i+1
            div *= i
            mul %= P
            div %= P
        
    return mul*modpow(div, P-2)%P

S = [A[0]%M]

for i in range(N-1):
    S.append((A[i+1]+S[i])%M)

counter = Counter(S)
lst = list(counter)

cnt = counter[0]
for j in range(len(lst)):
    cnt+=comb(counter[lst[j]], 2)
print(cnt)