def iin(): return int(input())
def nl(): return list(map(int, input().split()))

n, m = nl()
a = nl()

csum = [0]
for x in a:
    csum.append((csum[-1] + x) % m)

d = dict()
ans = 0
for x in csum:
    t = d.get(x, 0)
    ans += t
    d[x] = t + 1
    
print(ans)