def candy_distribution(N: int, M: int, A: list)->int:
    S = [0] * (N+1)
    for i, a in enumerate(A):
        S[i+1] = S[i] + a

    count = 0
    for l in range(1, N+1):
        for r in range(l, N+1):
            if (S[r] - S[l-1]) % M == 0:
                # print('S({}, {}) = {}'.format(l, r, S[r] - S[l-1]))
                count += 1

    return count


if __name__ == "__main__":
    N, M = map(int, input().split())
    A = [int(s) for s in input().split()]
    ans = candy_distribution(N, M, A)
    print(ans)
