N=int(input()) E=[[] for i in range(N+1)] for i in range(N-1): x,y=map(int,input().split()) E[x].append(y) E[y].append(x) Q=[1] TOP_SORT=[] USE=[0]*(N+1) USE[1]=1 P=[-1]*(N+1) while Q: x=Q.pop() TOP_SORT.append(x) for to in E[x]: if USE[to]==0: USE[to]=1 Q.append(to) P[to]=x Children=[1]*(N+1) for t in TOP_SORT[::-1]: if t!=1 and len(E[t])==1: Children[t]=1 if t!=1: Children[P[t]]+=Children[t] for i in range(1,N+1): ANS=Children[i]*2-1 X=[] for to in E[i]: if to==P[i]: continue X.append(Children[to]) S=sum(X) for x in X: ANS+=x*(S-x) print(ANS)