# 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 = []

# sym = 0
# cnt_zero = 0
# for i, A in enumerate(map(int, input().split())):
#     sym = (sym + A) % M
#     if sym > 0: Asym.append(sym)
#     else: cnt_zero += 1
    
# ans = cnt_zero * (cnt_zero + 1)
# for sym in set(Asym):
#     Asym.remove(sym)

# for sym in set(Asym):
#     cnt = Asym.count(sym)
#     ans += cnt * (cnt + 1)
        
# print(int(ans / 2))

Acnt = [0 for i in range(M)]
sym = 0

for A in map(int, input().split()):
    sym = (sym + A) % M
    Acnt[sym] += 1

print(int(Acnt[0] + sum([Acnt.count(i) * i * (i - 1) for i in range(1 + max(Acnt))]) / 2))