#include <bits/stdc++.h>

using namespace std;

int main() {
  int n;
  cin >> n;
  long long res = n;
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    if (x > y) swap(x, y);
    res -= (long long) x * (n - y + 1);
    res += (long long) (i + 1) * (n - i);
  }
  cout << res << '\n';
  return 0;
}
