
const int MaxN = 100000;
unsigned long long S[ MaxN + 10 ];

int main()
{
unsigned long long i;
unsigned long long N;
unsigned long long M;
unsigned long long A;
unsigned long long x;
unsigned long long iCnt;
unsigned long long iSum;

	scanf( "%llu%llu", &N, &M );

	iSum = 0;
	iCnt = 0;
	for( i = 1; i <= N; i++ )
	{
		scanf( "%llu", &A );

		iSum += A;
		iSum %= M;
		S[ i ] = iSum;
	}

	sort( S, S + ( N + 1 ) );

	x = 0;
	for( i = 1; i <= N; i++ )
	{
		if( S[ i - 1 ] == S[ i ] )
			x++;
		else
		{
			iCnt += ( x + 1 ) * x / 2;
			x = 0;
		}
	}

	if( x > 0 ) iCnt += ( x + 1 ) * x / 2;

	printf( "%llu\n", iCnt );

	return 0;
}




