import sys sys.setrecursionlimit(2*10**5) n = int(input()) e = [[] for i in range(n)] for i in range(n-1): a,b = map(int,input().split()) e[a-1].append(b-1) e[b-1].append(a-1) size = [0]*n def dfs(x,p=-1): s = 0 for nex in e[x]: if nex == p: continue s += dfs(nex,x) s += 1 size[x] = s return s dfs(0) ans = n*n for i in range(n): p = -1 c = 0 for nex in e[i]: if size[nex] > size[i]: p = nex else: ans += size[nex]*(n-size[nex]) c += size[nex] if p != -1: ans += (n-c-1)*(c+1) print(ans)