import math
from itertools import accumulate


n,m = map(int,input().split())

A = list(map(int,input().split()))

accum_A = [0] + A
accum_A = list(accumulate(accum_A))

ans = 0

for i in range(n):
    for j in range(i+1,n+1):
#         print('l:{}, r:{}, sum:{}'.format(i,j,(accum_A[j]-accum_A[i])))
        if (accum_A[j]-accum_A[i]) % m == 0:
            ans += 1

print(ans)
