# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np

def main():
	N, M = map(int, input().split(" "))
	A = list(map(int, input().split(" ")))
	
	ans = 0
	sum_list = []
	for i in range(N):
		if A[i] % M == 0:
			ans += 1
		if i == 0:
			sum_list.append(A[i])
			continue
		sum_list.append(A[i] + sum_list[i-1])
		if sum_list[i] % M == 0:
			ans += 1
	
	for i in range(1, N):
		for j in range(i+1, N):
			tmp = sum_list[j] - sum_list[i-1]
			if tmp % M == 0:
				ans += 1
		
	print(ans)
	
if __name__ == "__main__":
	main()
