fun main() = Thread(null, ::abc173f, "(^o^)", 128 * 1024 * 1024).apply { start() }.join()

@OptIn(ExperimentalStdlibApi::class)
fun abc173f() {
    val n = readLine()!!.toInt()
    val edges = (1 until n).map {
        val (u, v) = readLine()!!.split(' ').map { it.toLong() }.sorted()
        u to v
    }

    val sum = (1L..n).map { (it * (n - it + 1)) }.sum()
    val minus = edges.map { (u, v) -> u * (n - v + 1) }.sum()

    val answer = sum - minus

    println(answer)
}
