unittest
{
	assert( [ "5", "4 4 9 7 5" ].solve == 5 );
	assert( [ "6", "4 5 4 3 3 5" ].solve == 8 );
	assert( [ "10", "9 4 6 1 9 6 10 6 6 8" ].solve == 39 );
	assert( [ "2", "1 1" ].solve == 0 );
}



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

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

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto ls = input.front.split.to!( long[] );
	
	auto ans = 0L;
	ls.sort;
	foreach( i, a; ls )
	{
		foreach( j, b; ls[ i + 1 .. $ ] )
		{
			foreach( c; ls[ i + j + 1 .. $ ] )
			{
				ans += ( a != b && a != c && b != c && c < a + b );
			}
		}
	}
	return ans;
}
