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