#include <bits/stdc++.h>
using namespace std;
#define ll long long
vector<ll> G[200010];

int main() {
	ll N, u, v, a = 0, d = 0;
	cin >> N;
	for (int i = 1;i < N;i++) {
		cin >> u >> v;
		G[max(u, v)].push_back(min(u, v));
	}
	for (v = 1;v <= N;v++) {
		u = v;
		for (auto j : G[v])
			u -= j;
		d += u;
		a += d;
	}
	cout << a << endl;
}