program intervals_on_tree
  implicit none
  integer(8) :: n, i, u, v, x
  read(*,*) n
  x = n * (n + 1) * (n + 2) / 6
  do i = 1, n - 1
    read(*,*) u, v
    x = x - min(u, v) * (n - max(u, v) + 1)
  end do
  write(*,'(i0)') x
end program intervals_on_tree