import sys from collections import deque input = sys.stdin.buffer.readline N = int(input()) T = [[] for _ in range(N)] for _ in range(N - 1): a, b = (int(x) - 1 for x in input().split()) T[a].append(b) T[b].append(a) d = deque([(0, -1)]) dfs_order = [] while d: v, p = d.pop() for x in T[v]: if x == p: continue dfs_order.append((x, v)) d.append((x, v)) subtree_size = [1] * N for x, v in reversed(dfs_order): subtree_size[v] += subtree_size[x] ans = N * N for v in range(N): ans += subtree_size[v] * (N - subtree_size[v]) * 2 print(ans)