N = int(eval(input()))

ans = N * (N + 1) * (N + 2) // 6

for _ in range(N - 1):

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

    if u > v:

        u, v = v, u

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

print(ans)

import sys



input = sys.stdin.readline

N = int(eval(input()))

ans = N * (N + 1) * (N + 2) // 6

for _ in range(N - 1):

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

    if u > v:

        u, v = v, u

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

print(ans)

N = int(eval(input()))
ans = N * (N + 1) * (N + 2) // 6
for _ in range(N - 1):
    u, v = list(map(int, input().split()))
    if u > v:
        u, v = v, u
    ans -= u * (N + 1 - v)
print(ans)

import sys

input = sys.stdin.readline
N = int(eval(input()))
ans = N * (N + 1) * (N + 2) // 6
for _ in range(N - 1):
    u, v = list(map(int, input().split()))
    if u > v:
        u, v = v, u
    ans -= u * (N + 1 - v)
print(ans)

+import sys + +input = sys.stdin.readline