/*
 
@author
_      _          _                 _      _
\\    // /\    | | \  |     |    /\ \\    //     
 \\  // /__\   | |_/  |_____|   /__\ \\  //
  \\// /    \  | | \  |     |  /    \ \\//
   \/ /      \ | |_/  |     | /      \ \/
@ Indian Institute of Technology Bhilai

With practice comes perfection,
with knowledge comes wisdom.
Incorporate wisdom in you, practice will harvest better results.
Always learn from others, your method is good but someone's even better.
Results take time, run for wisdom, for innovation, for getting better.
Points are mere objects, either you solve first or you solve better.
Seek for betterment, for quality, pace is important but cannot outstand
the quality you persist.
Times are bad just as now but it'll improve, this is my passion and I promise 
I won't let it go. I'll build myself again like a fighter gets back up after 
being thrown to the ground.
I'll learn. I bet that. I promise that.
*/
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ul;
#define rep(i,n) for(ll i=0; i<n; i++)
#define rep1(i,n) for(ll i=1; i<=n; i++)
#define vi vector<ll>
#define vii vector<vector<ll> > 
#define vpi vector<pair<ll,ll> >
#define pb push_back
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define alla(arr,n) arr, arr+n
#define yes cout<<"YES\n"
#define no (cout<<"NO\n")
#define fsync ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll maxx = 1e9+7;

bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b){
    return a.fi<b.fi || (a.fi==b.fi && a.se<b.se);
}

ll inline power(ll a, ll b, ll p){
    a %= p;
    ll ans = 1;
    while(b>0){
        if(b & 1)
            ans = (ans*a)%p;
        a = (a*a)%p;
        b >>= 1;
    }
    return ans;
}

ll inv(ll n, ll p){
    return power(n,p-2, p);
}

bool inline isPrime(ll n) { 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
    return true; 
}

/* When life hits hard and you get a WA
   Check for overflow
   Check for array bounds
   Fucking check for n=1? case. g++ would give you correct answer. So dry run for n=1.
   Fucking do something.
*/

template<typename... T> void pr(T&&... args){ ((cout << args << " "), ...); cout << "\n"; }
template<typename... T> void rd(T&&... args){ ((cin >> args), ...); }
template<class T> void printv(T &v, bool one_indexed, ll size){if(size==-1) size=v.size(); if(one_indexed){rep1(i,size-1) cout << v[i] << " ";} else rep(i,size) cout << v[i] << " "; cout << "\n";}
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int dr[] = {0,1,0,-1,1,-1,1,-1};
int dc[] = {1,0,-1,0,1,1,-1,-1};

void solve(){
    ll n,ans=0,a,b;
    rd(n);
    rep1(i,n-1){
        ans+=i*(n-i+1);
        rd(a,b);
        if(a>b)
            swap(a,b);
        ans-=a*(n-b+1);
    }    
    pr(ans+n);
}   

int main(){
    fsync
    ll test=1;
    // cin >> test;
    while(test--){
        solve();
    }

}

// Observe first. (Binary search, Two pointers), prefix sums, dp, greedy


Measured memory_bytes: 3616