#include using namespace std; typedef long long ll; typedef long double ld; #define REP(i, n) for (int i = 0; i < (n); ++i) #define REPR(i, n) for (int i = n - 1; i >= 0; --i) #define FOR(i, m, n) for (int i = m; i < n; ++i) #define FORR(i, m, n) for (int i = m; i >= n; --i) #define ALL(v) (v).begin(),(v).end() templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b> e(nmx); vector c(nmx); ll ans=0; ll n; void dfs(int cur,int pre=-1){ for(int to:e[cur]){ if(to==pre) continue; dfs(to,cur); ans+=c[to]*(n-c[to]); c[cur]+=c[to]; } c[cur]++; ans+=c[cur]*(n-c[cur]); } int main(){ cin.tie(0); ios::sync_with_stdio(false); cin >> n; REP(i,n-1){ int a,b;cin >> a >> b; a--,b--; e[a].push_back(b); e[b].push_back(a); } dfs(0); cout << ans+n*n << endl; }