N, M = map(int,input().split())
a = [0] + list(map(int,input().split()))

total = 0
info = [0] * M
info[0] = 1

for i in range(1,N+1):
    total = (total + a[i]) % M
    info[total] += 1

#print(info)

ans = 0

for j in range(M):
    ans += (info[j] * (info[j] - 1)) // 2
    #print(ans)

print(ans)
