N, M = map( int, input().split())
A = list( map( int, input().split()))
SUM = [0]
for i in range(N):
    a = A[i]%M
    SUM.append(SUM[-1]+a)
ans = 0
for l in range(N):
    for r in range(l+1,N+1):
        if (SUM[r] - SUM[l])%M == 0:
            ans += 1
print(ans)