// #include using namespace std; #define fi first #define se second #define all(x) x.begin(), x.end() #define lch (o << 1) #define rch (o << 1 | 1) typedef double db; typedef long long ll; typedef unsigned int ui; typedef pair pint; typedef tuple tint; const int N = 1e5 + 5; const int INF = 0x3f3f3f3f; const ll INF_LL = 0x3f3f3f3f3f3f3f3f; vector a[N]; int siz[N]; ll sum[N]; void getSize(int u, int pa) { siz[u] = 1; sum[u] = 0; for (auto v: a[u]) { if (v == pa) continue; getSize(v, u); siz[u] += siz[v]; sum[u] += sum[v]; } sum[u] += siz[u]; } int n; ll ans = 0; void dfs(int u, int pa, int paSiz, ll paSum) { ans += (sum[u] - siz[u]) + paSum + n; for (auto v: a[u]) { if (v == pa) continue; int _paSiz = paSiz + siz[u] - siz[v]; ll _paSum = paSum + (sum[u] - sum[v] - siz[u]) + _paSiz; dfs(v, u, _paSiz, _paSum); } } int main() { ios::sync_with_stdio(0); cin >> n; for (int i = 1; i < n; i++) { int u, v; cin >> u >> v; a[u].push_back(v); a[v].push_back(u); } getSize(1, 0); dfs(1, 0, 0, 0); cout << ans << endl; return 0; }