# -*- coding: utf-8 -*-
from collections import defaultdict

N, M = map(int, input().split())
A_list = list(map(int, input().split()))

x = defaultdict(int)
y = defaultdict(int)

for i in range(N):
    temp = x.copy()
    x.clear()
    r = A_list[i] % M
    for t in temp.items():
        y[t[0]] = y[t[0]] + t[1]
        x[int(t[0] + r) % M] = t[1]
    x[r] += 1

print(int(x[0] + y[0]))
