import numpy as np
(n, m) = list(map(int, input().split()))
a = np.array(list(map(int, input().split()))).astype("int64") 
a = np.cumsum(a)
a %= m
count = np.sum(a == 0)
unique_key = np.unique(a)
counts = [np.sum(a == i) for i in unique_key]
counts = np.array(counts).astype("int64")
counts = counts * (counts - 1) // 2
print(count + np.sum(counts))