from sys import stdin
import numpy as np

N, M = [int(x) for x in stdin.readline().split()]
A = np.array([int(a) for a in stdin.readline().split()], dtype=np.int64)

cumsum_remainders = (np.hstack([0, A]) % M).cumsum() % M

total = 0
for remainder in np.unique(cumsum_remainders):
    count = (cumsum_remainders == remainder).sum()
    total += count * (count - 1) // 2
print(total)
