# 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

Asym = []
append = Asym.append
count = Asym.count

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

print(ans)
