unittest
{
	assert( [ "5", "1 1 2 1 2" ].parse.expand.solve == "2\n2\n3\n2\n3" );
	assert( [ "4", "1 2 3 4" ].parse.expand.solve == "0\n0\n0\n0" );
	assert( [ "5", "3 3 3 3 3" ].parse.expand.solve == "6\n6\n6\n6\n6" );
	assert( [ "8", "1 2 1 4 2 1 4 1" ].parse.expand.solve == "5\n7\n5\n7\n7\n5\n7\n5" );
}



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 )
{
	long[ long ] ns;
	foreach( a; as )
	{
		ns[ a ]++;
	}
	
	long[ long ] ps;
	auto pt = 0L;
	foreach( a, n; ns )
	{
		ps[ a ] = n * ( n - 1 ) / 2;
		pt += n * ( n - 1 ) / 2;
	}
	
	auto anss = new long[ as.length ];
	foreach( ref ans, a; lockstep( anss, as ) )
	{
		auto p = ( ns[ a ] - 1 ) * ( ns[ a ] - 2 ) / 2;
		ans = pt - ps[ a ] + p;
	}
	return anss.to!( string[] ).join( "\n" );
}
