from collections import Counter
from scipy.misc import comb

n, m = list(map(int, input().split(" ")))
a_list = list(map(int, input().split(" ")))

# 累積和modの作成
cum_list = [sum(a_list[:i+1]) % m for i in range(n)]
print(cum_list)

# 上で作成したリストが同じものの組合せを考える
count = Counter(cum_list)
ans = 0
for k in count.values():
    # print("===")
    # print(k)
    c = comb(k, 2, 1)
    # print(c)
    ans += c

ans += count[0]

print(int(ans))
