def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    count = 0

    B = [0 for _ in range(N+1)]
    for i in range(N):
        B[i+1] = B[i] + A[i]
    for i in range(N):
        for j in range(i, N):
            if (B[j+1]-B[i])%M == 0:
                count += 1
    return count

print(main())
