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



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

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

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nm = input.front.split.to!( long[] );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( nm[ 1 ], as );
}

auto solve( long m, long[] as )
{
	// 先頭に0をくっつけておくと後で楽
	as = 0L ~ as;
	
	// 累積和の配列に変換
	auto c = 0L;
	foreach( ref a; as )
	{
		a = c + a;
		c = a;
	}
	
	// 組み合わせをカウント
	auto ans = 0L;
	foreach( r; 1 .. as.length )
	{
		foreach( l; 0 .. r )
		{
			ans += ( ( as[ r ] - as[ l ] ) % m == 0 );
		}
	}
	
	return ans;
}
