n, m = map(int, input().split())
a = list(map(int, input().split()))
s = [0]
count = 0
for i in range(n):
    s.append(a[i] + s[i])
    if s[i+1] % m == 0:
        count += 1
for i in range(1, n):
    for j in range(i+1, n+1):
        if (s[j] - s[i]) % m == 0:
            count += 1

print(count)