import numpy as np

N = int(eval(input()))

num = 0

for i in range(1, N+1):

  num += i * (N+1-i)

for _ in range(N-1):

  u, v = list(map(int, input().split()))

  x, y = min(u, v), max(u, v)

  num -= (N+1-y) * x

print(num)
import numpy as np

N = int(eval(input()))

num = 0

for i in range(1, N+1):

  num += i * (N+1-i)

for _ in range(N-1):

  u, v = sorted(map(int, input().split()))

  num -= (N+1-v) * u

print(num)
import numpy as np

N = int(eval(input()))
num = 0
for i in range(1, N + 1):
    num += i * (N + 1 - i)
for _ in range(N - 1):
    u, v = list(map(int, input().split()))
    x, y = min(u, v), max(u, v)
    num -= (N + 1 - y) * x
print(num)

import numpy as np

N = int(eval(input()))
num = 0
for i in range(1, N + 1):
    num += i * (N + 1 - i)
for _ in range(N - 1):
    u, v = sorted(map(int, input().split()))
    num -= (N + 1 - v) * u
print(num)

-    u, v = list(map(int, input().split())) -    x, y = min(u, v), max(u, v) -    num -= (N + 1 - y) * x +    u, v = sorted(map(int, input().split())) +    num -= (N + 1 - v) * u