# -*- coding: utf-8 -*-
# import numpy as np

N, M = map(int, input().split())
An = list(map(int, input().split()))

Cn = [0]*(N+1)

for i,Ai in enumerate(An):
    if i == 0:
        Cn[i+1] = Ai
    else:
        Cn[i+1] = Cn[i] + Ai

# print(Cn)

# for l in range(1,N+1):
#     for r in range(l,N+1):
#         if (Cn[r] - Cn[l-1])%M == 0:
#             ans += 1

def func(n):
    if n <= 1:
        return 1
    else:
        return n * func(n - 1)


mod = {}
for i in range(N+1):
    if Cn[i]%M in mod:
        mod[Cn[i]%M] += 1
    else:
        mod[Cn[i]%M] = 1

# print(mod)

ans = 0
for val in mod.values():
    if val <= 1:
        continue
    elif val == 2:
        ans += 1
    else:
        tmp = func(val) / (func(2) * func(val - 2))
        ans += int(tmp)

print(ans)
