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

int main(){
    int N;
    cin >> N;
    ll ans = 0;
    for (ll i = 1; i <= N; i++) {
        ans += i*(N-i+1);
    }
    
    for (int i = 0; i < N-1; i++) {
        ll u, v;
        cin >> u >> v;
        if (u > v) swap(u, v);
        ans -= u * (N-v+1);
    }
    cout << ans << endl;
    return 0;
}