n,m = map(int,input().split())
a = list(map(int,input().split()))
sum = [0]
ans = 0
for i in range(n):
    sum.append(sum[-1] + a[i])
for l in range(n):
    for r in range(l,n):
        if (sum[r+1] - sum[l]) % m == 0:
            ans += 1
print(ans)