#include using namespace std; using graph = vector>; void dfs(const graph &to, vector &child, vector &par, int v, int p) { par.at(v) = p; for (auto &&i : to.at(v)) { if (i == p) continue; dfs(to, child, par, i, v); child.at(v) += child.at(i); } child.at(v)++; } int main(int argc, char const *argv[]) { int64_t n; cin >> n; graph to(n); for (int i = 0; i < n - 1; i++) { int a, b; cin >> a >> b; a--; b--; to.at(a).push_back(b); to.at(b).push_back(a); } vector child(n), par(n); dfs(to, child, par, 0, -1); assert(child.at(0) == n); int64_t ans = n * n * n; for (int i = 0; i < n; i++) { for (auto &&c : to.at(i)) { if (c == par.at(i)) continue; ans -= child.at(c) * child.at(c); } ans -= (n - child.at(i)) * (n - child.at(i)); } cout << ans << endl; return 0; }