import numpy as np

n, m = map(int, input().split())
aa = [int(ak) % m for ak in input().split()]
mod = np.zeros(m,dtype="i4")
ans = 0
for a in aa:
    mod=np.roll(mod,a)
    mod[a] += 1
    ans += mod[0]
print(ans)
