#include <bits/stdc++.h>
const int N = 5e5 + 10;
int ri() {
  char c = getchar();
  int x = 0, f = 1;
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') f = -1;
  for (; c >= '0' && c <= '9'; c = getchar()) x = (x << 1) + (x << 3) - '0' + c;
  return x * f;
}
struct P {
  long long x, y;
  P(long long _x = 0, long long _y = 0) : x(_x), y(_y) {}
  P operator+(P a) { return P(x + a.x, y + a.y); }
  P operator-(P a) { return P(x - a.x, y - a.y); }
  double operator*(P a) { 1.0 * x* a.y - 1.0 * y* a.x; }
} p[N];
double xmult(P a, P b, P c) { return (b - a) * (c - a); }
bool cmp(P a, P b) { return a.x < b.x; }
int sz[N], pr[N], nx[N << 1], to[N << 1], st[N], tp, tot, n;
long long ans, mn[N], C2[N];
void add(int u, int v) {
  to[++tp] = v;
  nx[tp] = pr[u];
  pr[u] = tp;
}
void adds(int u, int v) {
  add(u, v);
  add(v, u);
}
void Calc(int u, int fa) {
  sz[u] = 1;
  for (int i = pr[u]; i; i = nx[i])
    if (to[i] != fa) {
      Calc(to[i], u);
      sz[u] += sz[to[i]];
    }
}
long long Cal(P a, int k) { return a.x * k + a.y; }
void Up(long long x) { ans = std::min(ans, x); }
void Solve() {
  std::sort(p + 1, p + tp + 1, cmp);
  st[tot = 1] = 1;
  for (int i = 2; i <= tp; ++i) {
    for (; tot > 1 && Cal(p[st[tot - 1]], p[i].x) < Cal(p[st[tot]], p[i].x);
         --tot)
      ;
    Up(Cal(p[st[tot]], p[i].x) + p[i].y);
    st[++tot] = i;
  }
}
void Work(int u, int fa, long long v) {
  mn[u] = v + C2[sz[u]];
  for (int i = pr[u]; i; i = nx[i])
    if (to[i] != fa) {
      Work(to[i], u, v + C2[sz[u] - sz[to[i]]]);
      mn[u] = std::min(mn[u], mn[to[i]]);
    }
  tp = 0;
  for (int i = pr[u]; i; i = nx[i])
    if (to[i] != fa) {
      const long long V = mn[to[i]] - v - C2[sz[u] - sz[to[i]]];
      const long long S = sz[to[i]];
      p[++tp].x = S;
      p[tp].y = V - n * S + C2[S + 1];
    }
  p[++tp].x = 1;
  p[tp].y = -n + 1;
  Solve();
}
int main() {
  n = ri();
  tp = 1;
  for (int i = 1; i < n; ++i) adds(ri(), ri());
  for (int i = 1; i <= n; ++i) C2[i] = 1LL * i * (i - 1) >> 1;
  Calc(1, 0);
  Work(1, 0, 0);
  printf("%lld\n", C2[n] - ans);
  return 0;
}
