unittest
{
	assert( [ "3 2", "4 1 5" ].solve == 3 );
	assert( [ "13 17", "29 7 5 7 9 51 7 13 8 55 42 9 81" ].solve == 6 );
	assert( [ "10 400000000", "1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000" ].solve == 25 );
}



import std.conv;
import std.format;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = 0L;
	auto m = 0L;
	input.front.formattedRead!"%s %s"( n, m );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	
	auto ts = new long[ 1 + as.length ];
	foreach( i, a; as )
	{
		ts[ i + 1 ] = ts[ i ] + a;
	}
	
	auto ans = 0L;
	long[ long ] rs;
	foreach( i, t; ts )
	{
		auto r = t % m;
		if( r in rs ) ans += rs[ r ];
		rs[ r ]++;
	}
	return ans;
}
