import numpy as np
(n, m) = list(map(int, input().split()))
a = np.array(list(map(int, input().split())))
a = np.cumsum(a)
a %= m
count = np.sum(a == 0)
unique, counts = np.unique(a, return_counts=True) 
counts = np.array(counts)
counts = counts * (counts - 1) // 2
print(count + np.sum(counts))