#! /usr/bin/env python3

n, m = map(int, input().split())
a = [int(i) for i in input().split()]

acc = 0
res = 0

mods = {}

for i in range(n):
    acc = (acc + a[i]) % m

    if acc == 0:
         res += 1

    for k, v in mods.items():
        if acc == k:
            res += v

    if acc in mods:
        mods[acc] += 1
    else:
        mods[acc] = 1

print(res)
