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

    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)

    d = [i*(i-1)//2 for i in D]
    return sum(d)

print(main())
