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

    B = [0]*(N+1)
    C = [0,]
    D = [1,]
    for i in range(N):
        B[i+1] = B[i] + A[i]
        k = B[i+1] % M
        if k in C:
            D[C.index(k)] += 1
        else:
            C.append(k)
            D.append(1)

    for d in D:
        nn = d - 1
        count += nn*(nn+1)//2
    return count

print(main())
