unittest
{
	assert( [ "4", "3 4 2 1" ].parse.expand.solve == 1 );
	assert( [ "3", "1 1000 1" ].parse.expand.solve == 0 );
	assert( [ "7", "218 786 704 233 645 728 389" ].parse.expand.solve == 23 );
}



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

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

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

auto solve( long[] as )
{
	auto ans = 0L;
	auto as_s = as.sort();
	while( !as_s.empty )
	{
		auto a = as_s.front;
		as_s.popFront;
		auto bs_s = as_s;
		while( !bs_s.empty )
		{
			auto b = bs_s.front;
			bs_s.popFront;
			if( !bs_s.empty ) ans += bs_s.lowerBound( a + b ).length;
		}
	}
	return ans;
}
