# -*- coding: utf-8 -*-
# import numpy as np

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

Cn = [0]*(N+1)

for i,Ai in enumerate(An):
    if i == 0:
        Cn[i+1] = Ai
    else:
        Cn[i+1] = Cn[i] + Ai

# print(Cn)

ans = 0
for l in range(1,N+1):
    for r in range(l,N+1):
        if (Cn[r] - Cn[l-1])%M == 0:
            ans += 1

print(ans)
