# -*- coding: utf-8 -*-
from itertools import accumulate, combinations
from collections import defaultdict

n, m = map(int, input().split())
ary = [int(_) for _ in input().split()]

sum_ary = accumulate(ary, lambda x, y: x + y)
mod_table = defaultdict(int)
for mod in [s % m for s in sum_ary]:
    mod_table[mod] += 1
mod_table[ary[0] % m] += 1

print(sum([len(list(combinations(range(v), 2))) for v in mod_table.values()]))
