# D
N, M = map(int, input().split())
A_list = list(map(int, input().split()))

mod_dict = dict()

sum_k = 0
for a in A_list:
    sum_k += a
    r = sum_k % M
    if r not in mod_dict.keys():
        mod_dict[r] = 1
    else:
        mod_dict[r] += 1

res = 0
sum_k = 0

r = 0

for a in A_list:
    res += mod_dict[r]    
    sum_k += a
    r = sum_k % M
    mod_dict[r] -= 1
    
    
print(res)