object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val uv = List.fill(n-1)((sc.nextLong()-1, sc.nextLong()-1))
  var ans = 0L

  for (i <- 0L until n) {
    ans += (i+1) * (n-i)
  }

  for ((u, v) <- uv) {
    ans -= (u.min(v) + 1) * (n - u.max(v))
  }

  println(ans)
}
