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

print(num)