from collections import defaultdict
N, M = map(int, input().split())
A = list(map(int, input().split()))
dic = defaultdict(int)
num, s = 0, 0
dic[0] = 1
for i in A:
    s += i
    num += dic[s % M]
    dic[s % M] += 1

print(num)