# N = int(input())
N, M = map(int, input().split())
A = list(map(int, input().split()))
# d = [list(map(int, input().split())) for _ in range(N)]
# s = input()

def Solve(A_cum1, sa):
    ans_s = 0
    for i_s in range(len(A_cum1)):
        if i_s <= sa - 1:
            continue
        else:
            if i_s - sa - 1 == -1:
                if A_cum1[i_s] % M == 0:
                    ans_s += 1
            else:
                if (A_cum1[i_s] - A_cum1[i_s - sa - 1]) % M == 0:
                    ans_s += 1
    return ans_s

#
# def Cum(AA):
#     A_cum2 = []
#
#     for i_c in range(len(AA)):
#         if i_c == 0:
#             A_cum2.append(AA[0])
#         else:
#             A_cum2.append(A_cum2[i_c - 1] + AA[i_c])
#     return A_cum2

ans = 0
for A_i in A:
    if A_i % M == 0:
        ans += 1

A_cum = []

for i in range(len(A)):
    if i == 0:
        A_cum.append(A[0])
    else:
        A_cum.append(A_cum[i - 1] + A[i])

iii = 1
while len(A_cum)+1 != iii:
    ans += Solve(A_cum, iii)
    iii += 1
    # A_cum = Cum(A_cum)


print(ans)