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



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 );
	auto uvs = new long[ 2 ][ n - 1 ];
	foreach( ref uv; uvs )
	{
		input.popFront;
		uv = input.front.split.to!( long[] );
		uv[] -= 1;
	}
	
	// 全パターンの頂点数を合計
	auto ans = 0L;
	foreach( i; 0L .. n )
	{
		ans += ( i + 1 ) * ( n - i );
	}
	
	// 頂点数合計 - 辺数合計 = 連結成分数
	foreach( uv; uvs )
	{
		if( uv[ 0 ] < uv[ 1 ] ) ans -= ( uv[ 0 ] + 1 ) * ( n - uv[ 1 ] );
		else                    ans -= ( uv[ 1 ] + 1 ) * ( n - uv[ 0 ] );
	}
	return ans;
}
