var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
var abs = x=>x>0?x:-x;
function min(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<val)val = rest[i];return val}
function max(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>val)val = rest[i];return val}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split('\n');
	var nm = toIntArr(input[0].split(' '));
	var n = nm[0];
	var m = nm[1];
	var as = toIntArr(input[1].split(' '));
	var sums = [];
	sums[-1] = 0;
	for(var i = 0; i < n; i++){
		sums[i] = (sums[i-1] + as[i])%m;
	}
	var ans = 0;
	for(var l = 0; l < n; l++){
		for(var r = l; r < n; r++){
			if((sums[r]-sums[l-1])%m===0)ans++;
		}
	}
	console.log(ans);

}