unittest
{
	assert( [ "3", "3 1 2" ].parse.expand.solve == 11 );
	assert( [ "7", "5 0 7 8 3 3 2" ].parse.expand.solve == 312 );
}



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 ds = input.front.split.to!( long[] );
	return tuple( ds );
}

auto solve( long[] ds )
{
	auto ans = 0L;
	foreach( ai, a; ds )
	{
		foreach( b; ds[ ai + 1 .. $ ] )
		{
			ans += a * b;
		}
	}
	return ans;
}
