n, m = map(int, input().split())
list = list(map(int, input().split()))
sum = [0]
for i in range(n):
    sum.append( (list[i] + sum[i]) % m)
sum.sort()
sum.append(0)

count = 0
result = 0
for i in range(1, n + 2):
    if sum[i] == sum[i - 1]:
        count += 1
    else:
        result += count * (count + 1) // 2
        count = 0
print(result)