#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;

signed main(){
    ll n;
    cin>>n;
    ll ans = n;
    for(int i=1;i<n;i++){
        ans += (i+1)*(n-i);
        ll a,b;
        cin>>a>>b;
        if(a>b)swap(a,b);
        ans -= a*(n-b+1);
    }
    cout << ans << endl;
}