import numpy as np

n, m = map(int, input().split())
a = [0] + list(map(int, input().split()))

a = np.array(a)

_, c = np.unique(np.cumsum(a % m) % m, return_counts=True)

print((c * (c - 1)).sum() // 2)