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