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

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

cum = [0] * N
cum[0] = A[0]
for i in range(1,N):
    cum[i] = cum[i-1] + A[i]

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

            

print(ans)
