# 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

if N < M:

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

else:

    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([cnt * (cnt - 1) for cnt in Acnt]) / 2))