from collections import Counter
N, M = map(int, input().split())
A = list(map(lambda x:int(x)%M, input().split()))
B = A[:]
for i in range(N-1):
    B[i+1] += B[i]
    B[i+1] %= M
c = Counter(B)

def ncr(n, r, p):
    num = den = 1
    for i in range(r):
        num = (num * (n - i)) % p
        den = (den * (i + 1)) % p
    return (num * pow(den, p - 2, p)) % p
p=10**9+7

ans = 0
for k, v in c.items():
    if k == 0:
        ans += v
    if v >= 2:
        ans += ncr(v, 2, p)
print(ans)