#include using namespace std; using ll = long long; int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); ll N, A, B; cin >> N; vector> E(N); for (int i=0; i < N-1; i++){ cin >> A >> B; A--; B--; E[A].push_back(B); E[B].push_back(A); } //部分木のサイズ vector subt(N); auto subtree_size=[&](auto self, int from, int p)->void{ subt[from]=1; for (auto to : E[from]){ if (to == p) continue; self(self, to, from); subt[from] += subt[to]; } }; subtree_size(subtree_size, 0, -1); //各頂点の親 const int LOG=1; vector par(LOG, vector(N, -1)); auto ancestor=[&](auto self, int from, int p)->void{ for (auto to : E[from]){ if (to == p) continue; par[0][to] = from; self(self, to, from); } }; ancestor(ancestor, 0, -1); for (int i=0; i v; for (auto x : E[i]){ if (x != par[0][i]){ v.push_back(subt[x]); S += subt[x]; } } for (auto x : v) ans += x*(S-x); cout << ans + subt[i]*2-1 << endl; } return 0; }