# encoding: utf-8
N, M = list(map(int, input().split()))

# TLE
# Amod = [A for A in map(lambda x: int(x) % M , input().split())]
# ans = 0
# for l in range(len(Amod)):
#     acm = 0
#     for r in range(l, len(Amod)):
#         acm = (acm + Amod[r]) % M
#         if acm == 0: ans += 1

for i, A in enumerate(map(int, input().split())):
    if i == 0: Asym = [A % M]
    else: Asym.append((Asym[-1] + A) % M)
# print(Asym)
    
ans = Asym.count(0)
for sym in set(Asym):
    # print(sym, Asym.count(sym), ans)
    cnt = Asym.count(sym)
    ans +=  int(cnt * (cnt -  1) / 2)

print(ans)

