# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect

def ln():
    return map(int, input().split())


N,M = ln()
A = list(ln())

SUM = [0 for i in range(N+1)]

for i in range(N):
    SUM[i+1] = SUM[i] + A[i]
    SUM[i+1] %= M
ans = 0

for i in range(N):
    ans += SUM[i+1:].count(SUM[i])

print(ans)
