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

ll n;
ll en = 0;

int main() {
	cin >> n;
	for (int i = 0; i < n - 1; ++i) {

		int u, v;
		cin >> u >> v;
		if (v < u)
			swap(u, v);
		en += (ll) u * (n - v + 1);
	}

	cout << n * (n * n + 3 * n + 2) / 6 - en << endl;

}
