import numpy as np
n,m = list(map(int,input().split()))
a = list(map(int,input().split()))
a = [aa%m for aa in a]

def check(temp):
    return(len(np.where(temp%m == 0)[0]))

ans = 0
temp = np.cumsum(a)
for k in range(len(a)):
    ans += (check(temp))
    temp = temp[1:] - a[k]
print(ans)