def main():
	N, M = map(int, input().split())
	A = list(map(int, input().split()))
	sums = [0]*(N+1)
	for i in range(N+1):
		sums[i] = sums[i-1] + A[i-1]

	ans = 0
	for i in range(N+1):
		for j in range(i+1, N+1):
			if (sums[j] - sums[i]) % M == 0:
				ans += 1
	print(ans)

if __name__ == '__main__':
    main()