#include using namespace std; #pragma region Macros #ifdef ONLINE_JUDGE #define dbg(x) 0 #else #define dbg(x) cout << __LINE__ << " : " << #x << " = " << (x) << endl; #endif using ll = long long; using ull = unsigned long long; using pii = pair; using pll = pair; using plll = pair; using db = double; using ld = long double; templateusing vc = vector; templateusing vvc = vector>; templateusing vvvc = vector>; templateusing vvvvc = vector>; templateusing vvvvvc = vector>; templateusing vvvvvvc = vector>; templateusing vvvvvvvc = vector>; templateusing vvvvvvvvc = vector>; #define rep(i,n) for(int i=0;i<(n);i++) #define drep(i,n) for(int i=(n);i>=0;i--) #define DREP(i,n,m) for(int i=(n);i>=(m);i--) #define REP(i,n,m) for(int i=n;i<(m);i++) #define fi first #define se second #define pb push_back #define eb emplace_back #define mp make_pair #define ti tuple #define tl tuple #define mt make_tuple #define all(nAdjNhqW) (nAdjNhqW).begin(), (nAdjNhqW).end() #define rall(n) n.rbegin(),n.rend() #define YESNO(bool) if(bool){cout<<"YES"<> #define vvl vector> #define vvvl vector #define vvvvl vector #define vi vector #define vp vector #define vpl vector #define ge(vEqMgDq5,i) get(vEqMgDq5) #define vl vector #define vs vector #define vvvi vector #define vb vector #define vvb vector> #define vvvb vec #define vs vector #define vvs vector #define vd vector #define vvd vector #define vld vector #define vvld vector #define pque priority_queue #define smpq(n) priority_queue,greater> #define bipq(n) priority_queue,less> #define piii pair> #define ednl endl #define denl endl #define Endl endl #define Yes cout<<"Yes"< inline bool chmax(T& a, U b) { return ((a < b) ? (a = b, true) : (false)); } template inline bool chmin(T& a, U b) { return ((a > b) ? (a = b, true) : (false)); } int zero() { return 0; } ll zerol() { return 0ll; } int plu(int a, int b) { return a + b; } int mini(int a, int b) { return min(a, b); } int maxi(int a, int b) { return max(a, b); } ll plusl(ll a, ll b) { return a + b; } ll minl(ll a, ll b) { return min(a, b); } int infi() { return inf; }; ll infl() { return INF; } int dx[] = { -1,0,1,0 ,1,1,-1,-1 }; int dy[] = { 0 ,1,0,-1,1,-1,1,-1 }; template vector sorted(vector& a) { auto f = a; sort(all(f)); return f; } string sorted(string s) { sort(all(s)); return s; } templatevectorreversed(vector& a) { auto f = a; reverse(all(f)); return f; } string reversed(string s) { reverse(all(s)); return s; } template vector operator++(vector& v, int) { for (auto& x : v)x += 1; return v; } template vector operator--(vector& v, int) { for (auto& x : v) x -= 1; return v; } template pair operator++(pair& p, int) { p.first++; p.second++; return p; } template pair operator--(pair& p, int) { p.first--; p.second--; return p; } template vector operator-(vector v, U s) { for (auto& x : v) x -= s; return v; } template vector operator-=(vector& v, U s) { for (auto& x : v) x -= s; return v; } template vector operator+(vector v, U s) { for (auto& x : v) x += s; return v; } template vector operator+=(vector& v, U s) { for (auto& x : v) x += s; return v; } template vector operator*(vector v, U s) { for (auto& x : v) x *= s; return v; } template vector operator*=(vector& v, U s) { for (auto& x : v) x *= s; return v; } template vector operator/(vector v, U s) { for (auto& x : v) x /= s; return v; } template vector operator/=(vector& v, U s) { for (auto& x : v)x /= s; return v; } template pair operator-(pair p, S n) { p.fi -= n; p.se -= n; return p; } template pair operator-=(pair& p, S n) { p.fi -= n; p.se -= n; return p; } template pair operator+(pair p, S n) { p.fi += n; p.se += n; return p; } template pair operator+=(pair& p, S n) { p.fi += n; p.se += n; return p; } template pair operator*(pair p, S n) { p.fi *= n; p.se *= n; return p; } template pair operator*=(pair& p, S n) { p.fi *= n; p.se *= n; return p; } template pair operator/(pair p, S n) { p.fi /= n; p.se /= n; return p; } template pair operator/=(pair& p, S n) { p.fi /= n; p.se /= n; return p; } template ostream& operator<<(ostream& os, const pair& p) { os << "{" << p.first << "," << p.second << "}" << endl; return os; } template istream& operator>>(istream& is, pair& p) { is >> p.first >> p.second; return is; } #if __has_include() #include using namespace atcoder; ostream& operator<<(ostream& os, modint m) { os << m.val(); return os; } #endif template istream& operator>>(istream& is, vector& v) { for (int i = 0; i < v.size(); i++) is >> v[i]; return is; } template ostream& operator<<(ostream& os, const vector& v) { for (int i = 0; i < v.size(); i++) { if (i) os << " "; os << v[i]; } os << endl; return os; } template ostream& operator<<(ostream& os, const map& m) { for (const auto& [x, y] : m) os << "{" << x << "," << y << "}" << endl; return os; } template ostream& operator<<(ostream& os, const set& s) { for (const auto& x : s) os << x << " "; os << endl; return os; } template pair operator+(pair p, pair q) { p.first += q.first; p.second += q.second; return p; } template pair operator-(pair p, pair q) { p.first -= q.first; p.second -= q.second; return p; } string operator*(const string& s, int n) { string ret = ""; for (int i = 0; i < n; i++) ret += s; return ret; } string operator*=(string& s, int n) { s = s * n; return s; } template void print(T s) { cout << s << endl; } template void print(vc& v) { for (int i = 0; i < v.size(); i++)cout << v[i] << " "; cout << endl; } template void print(vvc& v) { For(x, v)print(x); return; } templatevoid print(T&... a) { (cout << ... << a); return; } templatevoid read(T&... a) { (cin >> ... >> a); } templateT read() { T s; cin >> s; return s; } vi viread(int n) { vi a(n); cin >> a; return a; } vl vlread(int n) { vl a(n); cin >> a; return a; } vs vsread(int n) { vs a(n); cin >> n; return a; } int iread() { int s = read(); return s; } ll lread() { ll s = read(); return s; } string sread() { string s = read(); return s; } char cread() { char s = read(); return s; } template T min(const vector& v) { return *min_element(all(v)); } template T max(const vector& v) { return *max_element(all(v)); } template vector vread(int n) { vectorv(n); rep(i, n)read(v[i]); return v; } vvi readgraph(int n, int m) { vvi road(n); rep(i, m) { int a, b; cin >> a >> b; a--; b--; road[a].pb(b); road[b].pb(a); } return road; } vvi readtree(int n) { return readgraph(n, n - 1); } templatevector presum(vector& v) { vector s(v.size() + 1); rep(i, v.size())s[i + 1] = s[i] + v[i]; return s; } #define INT(...) int __VA_ARGS__; read(__VA_ARGS__) #define LL(...) ll __VA_ARGS__; read(__VA_ARGS__) #define CH(...) char __VA_ARGS__; read(__VA_ARGS__) #define STR(...) string __VA_ARGS__; read(__VA_ARGS__) #define VC(a,b,c) vector b(c);read(b); #define VVC(a,b,c,d)vvcb(c,vc(d));read(b); template vector zaatu(vector& v) { auto f = v; sort(all(f)); f.erase(unique(all(f)), f.end()); for (auto& x : v) { x = lower_bound(all(f), x) - f.begin(); } return v; } template vector> rotate(vector>& v) { vector>ret(v[0].size(), vector(v.size())); for (int i = 0; i < v[0].size(); i++)for (int j = 0; j < v.size(); j++) { ret[i][j] = v[j][i]; } return ret; } //return their min and max template pair mmp(T s, S t) { return make_pair(min(s, t), max(s, t)); } //O(NlogN) return if they are all different from others template bool all_unique(vector& v) { sets; for (auto x : v)s.is(x); return s.size() == v.size(); } //return if they are all same template bool all_same(std::vector& v) { for (int i = 0; i + 1 < v.size(); i++) { if (v[i] != v[i + 1])return false; } return true; } std::vectoremp; //return if it is bipartite graph .if you give it x it wil also return an example to paint it bool is_two(vvi& road, vi& x = emp) { if (x == emp)x.resize(road.size(), -1); rep(i, road.size()) { if (x[i] == -1) { queueque; que.push(i); x[i] = 0; while (que.size()) { auto p = que.front(); que.pop(); for (auto y : road[p]) { if (x[y] == -1) { x[y] = 1 - x[p]; que.push(y); } else { if (x[y] != 1 - x[p]) { return false; } } } } } } return true; } //return char and numbers of that vector> run_length(const std::string& s) { std::pairpre = { 'a',0 }; std::vector>ret; for (auto x : s) { if (pre.first == x) { pre.second++; } else { if (pre.second)ret.push_back(pre); pre = { x,1 }; } } ret.push_back(pre); return ret; } template < typename T > std::string to_string(const T& n) { std::ostringstream stm; stm << n; return stm.str(); } template int cnts(std::vector& v, T tmp, std::functionf) { int ret = 0; for (auto x : v) { if (f(x, tmp))ret++; } return ret; } //math ll Pow(ll a, ll b) { ll res = 1; rep(i, b) { res *= a; }return res; } ull POW(ull a, ull b) { ull res = 1; rep(i, b) { res *= a; }return res; } long long modpow(long long a, long long b, long long m) { if (a % m == 0)return 0; long long p = 1, q = a; q %= m; if (b < 0)return 0; for (int i = 0; i < 63; i++) { if ((b & (1LL << i)) != 0) { p *= q; p %= m; }q *= q; q %= m; }return p; } ll modinv(ll n, ll mod) { return modpow(n, mod - 2, mod); } ll gcd(ll a, ll b) { if (a == 0)return b; if (b == 0)return a; if (a % b == 0) { if (b > 0)return b; else return -b; } else { return gcd(b, a % b); } } ll lcm(ll a, ll b) { return a * b / gcd(a, b); } #pragma endregion //https://atcoder.jp/contests/abc312/submissions/48490412 int n; vvi road; long long ans = 0; int dfs(int now,int par) { int s = 1; for (auto x : road[now]) { if (x == par)continue; int t=dfs(x,now); s +=t; ans += (ll)t *(n - t+1); ans+=(ll)(t+1)*(n-t); } return s; } void dfs2(int now, int par) { } void solve() { cin >> n; ans = n ; road= readtree(n); dfs(0, -1); cout << ans << endl; } signed main() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(20); int t = 1; rep(i, t)solve(); return 0; }