from collections import defaultdict
n, m = map(int, raw_input().split())
A = map(int, raw_input().split())
prefix = [-1]*n
prefix[0] = A[0]
for i in range(1, n):
    prefix[i] = A[i] + prefix[i-1]
modulos = map(lambda x: x % m, prefix)
hashTable = defaultdict(int)
for modulo in modulos:
    hashTable[modulo] += 1
res = 0
for k, v in hashTable.items():
    if v >= 2:
        res += v*(v-1) /2
    if k == 0:
        res += v
print res