import time

def main():
    N, M = [int(n) for n in input().split()]
    imos = [[0]*N for _ in range(N)]
    for i, num in enumerate([int(n) for n in input().split()]):
        imos[i][i] = num
    
    _time = time.time()

    for h in range(N):
        for w in range(N-1):
            imos[h][w+1] += imos[h][w]
    for h in reversed(list(range(1, N))):
        for w in range(N):
            imos[h-1][w] += imos[h][w]
    ans = 0
    for h in range(N):
        for w in range(N):
            if imos[h][w] % M == 0:
                ans += 1
    print(ans)
    print(time.time() - _time)

    


main()
