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

class Cumulative_Sum:
    def __init__(self, a):
        la = len(a)
        self.s = [0] * (la + 1)
        for i in range(la):
            self.s[i+1] = self.s[i] + a[i]
    # s[l]からs[r]までの和
    def sum(self, l, r):
        return self.s[r] - self.s[l]

cs = Cumulative_Sum(a)

ans = 0
for i in range(0, n):
    for j in range(i+1, n+1):
        if cs.sum(i, j) % m == 0:
            ans += 1
print(ans)