(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
unique_a = {a[0] % m: 1}
for i in range(1, n):
    a[i] += a[i - 1]
    a[i] %= m
    if a[i] in unique_a:
        unique_a[a[i]] += 1
    else:
        unique_a[a[i]] = 1
count = unique_a[0]
for k in unique_a:
    count += unique_a[k] * (unique_a[k] - 1) // 2
print(count)