from itertools import accumulate
n,m = [int(a) for a in input().strip().split(' ')]
As = accumulate([int(a)%m for a in input().strip().split(' ')])
As = [0] + [i%m for i in As]

def isok(i,j):
    di = As[j] - As[i-1]
    if di % m == 0:
        return True
    else:
        return False


counter = 0
for i in range(n):
    for j in range(i, n):
        if isok(i+1, j+1):
            counter += 1
print(counter)
