from collections import defaultdict

N, M = map(int, input().split())
A = list(map(int, input().split()))
A = [a % M for a in A]

dp = [defaultdict(int) for _ in range(N + 1)]

for i, a in enumerate(A, start=1):
    dp[i][a] += 1
    for s, cnt in dp[i - 1].items():
        dp[i][(s + a) % M] += cnt

ans = 0
for cnt in dp[1:]:
    ans += cnt[0]

print(ans)