#include <bits/stdc++.h>
using ul = std::uint32_t;
using li = std::int32_t;
using ll = std::int64_t;
using ull = std::uint64_t;
using lf = double;
using vul = std::vector<ul>;
using vvul = std::vector<vul>;
using pulul = std::pair<ul, ul>;
ul n;
class edge {
 public:
  ul nex = ~ul(0);
  ul to = 0;
};
class node {
 public:
  ll f = 0;
  ll g = 0;
  ll cnt = 1;
  ul head = ~ul(0);
};
edge edg[999998];
node nod[500001];
ul sz = 0;
std::vector<node> nv;
std::vector<node> stack;
void addedge(ul u, ul v) {
  edg[sz].to = v;
  edg[sz].nex = nod[u].head;
  nod[u].head = sz;
  ++sz;
}
ll ans = (ull(1) << 63) - 1;
ll cp(ll x) { return x * (x - 1) >> 1; }
void minn(ll a, ll& b) { b = std::min(a, b); }
void search(ul curr, ul prev) {
  for (ul i = nod[curr].head; ~i; i = edg[i].nex) {
    ul nex = edg[i].to;
    if (nex == prev) {
      continue;
    }
    search(nex, curr);
    nod[curr].cnt += nod[nex].cnt;
  }
  auto& temp = nv;
  temp.resize(0);
  for (ul i = nod[curr].head; ~i; i = edg[i].nex) {
    ul nex = edg[i].to;
    if (nex == prev) {
      continue;
    }
    temp.push_back(nod[nex]);
  }
  std::sort(temp.begin(), temp.end(), [&](const node& a, const node& b) {
    return a.g + cp(nod[curr].cnt - a.cnt) < b.g + cp(nod[curr].cnt - b.cnt);
  });
  nod[curr].g =
      temp.size() ? temp[0].g + cp(nod[curr].cnt - temp[0].cnt) : ll(0);
  nod[curr].f =
      -(nod[curr].g << 1) + (-nod[curr].cnt + n + n - 1) * nod[curr].cnt;
  std::sort(temp.begin(), temp.end(),
            [&](const node& a, const node& b) { return a.cnt < b.cnt; });
  if (temp.size() == 0) {
    minn(cp(n), ans);
  } else if (temp.size() == 1) {
    minn(temp[0].g + cp(n - temp[0].cnt), ans);
  } else {
    stack.resize(0);
    for (const auto& no : temp) {
      if (stack.size()) {
        ul l = 0, r = stack.size();
        while (l + 1 != r) {
          ul mid = l + r >> 1;
          ul midm = mid - 1;
          if ((stack[mid].f - stack[midm].f) >=
              (stack[mid].cnt - stack[midm].cnt) * (no.cnt << 1)) {
            l = mid;
          } else {
            r = mid;
          }
        }
        const auto& np = stack[l];
        minn(cp(n - np.cnt - no.cnt) + np.g + no.g, ans);
      }
      while (stack.size() > 1) {
        const auto& t = stack.back();
        const auto& s = stack[stack.size() - 2];
        if ((no.f - t.f) * (t.cnt - s.cnt) >= (t.f - s.f) * (no.cnt - t.cnt)) {
          stack.pop_back();
        } else {
          break;
        }
      }
      stack.push_back(no);
    }
  }
}
int main() {
  std::scanf("%u", &n);
  for (ul i = 1; i != n; ++i) {
    ul u, v;
    std::scanf("%u%u", &u, &v);
    addedge(u, v);
    addedge(v, u);
  }
  search(1, 0);
  std::printf("%lld\n", (cp(n) << 1) - ans);
  return 0;
}
