numBox, numnClild = [int(i) for i in input().split()]
numCandies = [int(i) for i in input().split()]

def find(left):
    acc = 0
    for i in range(left, numBox):
        acc += numCandies[i]
        if acc % numnClild == 0:
            return i + 1
    return -1

done_list = []
count = 0
for left in range(0, numBox):
    tmp_count = 0
    right = left
    while right != -1:
        right = find(right)
        if right != -1:
            if right in done_list:
                break
            else:
                done_list.append(right)
                tmp_count += 1
    count += int(tmp_count * (tmp_count + 1) / 2)
print(count)