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

A = list(map(int, input().split()))
"""
if N == 1:
    if A[0] % M == 0:
        print(1)
        exit()
"""

ans = 0
cum = [0] * N
cum[0] = A[0]
if cum[0] % M == 0:
    ans += 1

for i in range(1,N):
    cum[i] = cum[i-1] + A[i]
    if cum[i] % M == 0:
        ans += 1

for l in range(N-1): 
    for r in range(l+1,N):
        #print(l,r)
        if (cum[r] - cum[l]) % M == 0:
             ans += 1

            

print(ans)
