import time
import math

def main():
    N, M = [int(n) for n in input().split()]
    A = [int(n) for n in input().split()]
    B = [0]*(N+1)
    B[0] = 0
    d = {}
    for i in range(N):
        B[i+1] = B[i] + A[i]
    for i, b in enumerate(B):
        x = b % M
        if x in d.keys():
            d[x] += 1
        else:
            d[x] = 1
    # print(B)
    print(sum([C(i, 2) for i in d.values()]))
        
c = {}
f = math.factorial
def C(n, r):
    if (n, r) in c.keys():
        return c[n, r]
    if n < 0 or r<0 or n<r:
        return 0
    c[(n, r)] = f(n) // (f(n-r) * f(r))
    return c[(n, r)]


# import os,sys, time

# current = os.path.abspath(__file__ + "/..")+"/"
# fdr = open(current + "d-case1.txt", "r")
# sys.stdin = fdr
# t = time.time()
# main()
# print(time.time() - t)

main()
