import numpy as np


n,m = input().split()

n = int(n)
m = int(m)

a = input().split()
a = [int(i) for i in a]

ans = 0

sumlist = list(np.cumsum(a))
for i in range(n):
    # print(sumlist)
    # for j in range(len(sumlist)):
    #     if sumlist[j] % m == 0:
    #         ans += 1
    # tmp = [x for x in sumlist if x % m == 0]
    # ans += len(tmp)
    #

    for j in range(len(sumlist)-i):
        # print(i,j,j+i-1)
        if i == 0:
            if sumlist[j] % m == 0:
                # print(sumlist[j])
                ans += 1

        elif (sumlist[j+i-1] - sum(sumlist[0:i-1])) % m == 0:
            # print(sumlist[j])
            ans += 1

    # print(ans)
    # sumlist = list(map(lambda x:x - sumlist[0],sumlist))
    # sumlist.pop(0)
print(ans)
