let N = Int(readLine()!)!
var sumE = 0
for _ in 1...N-1 {
    let line = readLine()!.split(separator: " ").map { Int($0)! }.sorted()
    let (u, v) = (line[0], line[1])
    sumE += u * (N-v+1)
}

let sumV = N*(N+1)*(N+2) / 6
print(sumV - sumE)
