n, m = map(int, input().split())
lst = list(map(int, input().split()))
dp = {}
dp[0] = 1
a, s = 0, 0
for i in lst:
    a += i
    a %= m
    if a in dp:
        s += dp[a]
        dp[a] += 1
    else:
        dp[a] = 1
print(s)