import os, sys, re, math

N,M = list(map(int,input().split(' ')))
ary = list(map(int,input().split(' ')))

s = [0 for i in range(N+1)]
for i in range(N):
    s[i+1] = ary[i] + s[i]

cnt = 0
for j in range(N,0,-1):
    for k in range(j,0,-1):
        if j == k:
            if s[j] % M == 0 and s[j] >= M:
                cnt += 1
        elif (s[j] - s[k]) % M == 0:
            cnt += 1
print(cnt)
