n, m = map(int, input().split())
a = list(map(int, input().split()))

ans = 0

x = 0

for i in range(n):
    for j in range(n-i):
        x += a[i+j]
        x %= m
        if x == 0:
            ans +=1
    x = 0

print(ans)