# encoding: utf-8
N, M = list(map(int, input().split()))

d_sym = {}
sym = 0

# refresh

for A in map(int, input().split()):
    sym = (sym + A) % M
    if str(sym) in d_sym: d_sym[str(sym)] += 1
    else: d_sym[str(sym)] = 1

print(int(d_sym["0"] + sum([val * (val - 1) / 2 for val in d_sym.values()])))