let N = Int(readLine()!)!

var V = 0
var E = 0

for i in 1...N {
  V += i * (N - i + 1)
}

for _ in 0..<N-1 {
  let inp = readLine()!.split(separator: " ").map { Int($0)! }
  var left = inp[0]
  var right = inp[1]
  if left > right {
    (right, left) = (left, right)
  }
  E += left * (N - right + 1)
}
print(V - E)