# encoding: utf-8

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



d_sym = {}

sym = 0



# refresh



ans = 0

for A in map(int, input().split()):

    sym = (sym + A) % M

    #

    if sym == 0: ans += 1

    # 

    if str(sym) in list(d_sym.keys()): d_sym[str(sym)] += 1

    else: d_sym[str(sym)] = 1



print((int(ans + sum([val * (val - 1) / 2 for val in list(d_sym.values())]))))

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

A = list(map(int, input().split()))



tab_sum = [0]

sum_tmp = 0

for Ai in A:

    sum_tmp += Ai

    tab_sum.append(sum_tmp)



cnt = {}

for item in tab_sum:

    key = str(item % M)

    cnt.setdefault(key, 0)

    cnt[key] += 1



    

ans = 0

for key, val in list(cnt.items()):

    ans += val * (val - 1) // 2



print(ans)
# encoding: utf-8
N, M = list(map(int, input().split()))
d_sym = {}
sym = 0
# refresh
ans = 0
for A in map(int, input().split()):
    sym = (sym + A) % M
    #
    if sym == 0:
        ans += 1
    #
    if str(sym) in list(d_sym.keys()):
        d_sym[str(sym)] += 1
    else:
        d_sym[str(sym)] = 1
print((int(ans + sum([val * (val - 1) / 2 for val in list(d_sym.values())]))))

N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
tab_sum = [0]
sum_tmp = 0
for Ai in A:
    sum_tmp += Ai
    tab_sum.append(sum_tmp)
cnt = {}
for item in tab_sum:
    key = str(item % M)
    cnt.setdefault(key, 0)
    cnt[key] += 1
ans = 0
for key, val in list(cnt.items()):
    ans += val * (val - 1) // 2
print(ans)

-# encoding: utf-8 -d_sym = {} -sym = 0 -# refresh +A = list(map(int, input().split())) +tab_sum = [0] +sum_tmp = 0 +for Ai in A: +    sum_tmp += Ai +    tab_sum.append(sum_tmp) +cnt = {} +for item in tab_sum: +    key = str(item % M) +    cnt.setdefault(key, 0) +    cnt[key] += 1 -for A in map(int, input().split()): -    sym = (sym + A) % M -    # -    if sym == 0: -        ans += 1 -    # -    if str(sym) in list(d_sym.keys()): -        d_sym[str(sym)] += 1 -    else: -        d_sym[str(sym)] = 1 -print((int(ans + sum([val * (val - 1) / 2 for val in list(d_sym.values())])))) +for key, val in list(cnt.items()): +    ans += val * (val - 1) // 2 +print(ans)