def solve():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    ans = 0
    for l in range(0, N):
        s = 0
        for r in range(l, N):
            s += A[r]
            if s % M == 0:
                ans += 1
    return ans

print(solve())
