#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll n;
	cin>>n;

	ll ans = (n * (n + 1) * (n + 2)) / 6;
	//cout<<ans<<endl;

	ll x,y;
	for(ll i = 0;i < n -1;i++) {
		cin>>x>>y;
		if(x > y)
			swap(x,y);
		ans-=(x * (n - y + 1));
	}

	cout<<ans<<"\n";
	return 0;
}