N, M = [int(x) for x in input().split()]

sum_c = 0
dic = {0:1}
for x in input().split():
    x = int(x)
    sum_c += x
    a = sum_c//M
    
    if dic.get(a,0) == 0:
        dic[a] = 1
    else:
        dic[a] += 1

ans = 0
ans += dic[0]*(dic[0]-1)

for v in dic.values():
    ans += v*(v-1)

print(ans)