#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
int n, tot, tp, top, u, v, q[500086], st[500086], h[500086];
long long sze[500086], f[500086];
long long ans = INF;
struct edge {
  int v, nxt;
} e[1000086];
long long Min(long long a, long long b) { return a < b ? a : b; }
long long sq(long long x) { return x * x; }
long long y(int x) { return 2 * n * sze[x] - f[x] - sq(sze[x]); }
double k(int a, int b) {
  if (sze[a] == sze[b]) return y(b) > y(a) ? INF : -INF;
  return (double)(y(b) - y(a)) / (sze[b] - sze[a]);
}
bool cmp(int a, int b) { return sze[a] < sze[b]; }
int read() {
  char ch = getchar();
  int nn = 0, ssss = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') ssss *= -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    nn = nn * 10 + (ch - '0');
    ch = getchar();
  }
  return nn * ssss;
}
bool add(int u, int v) {
  e[++tot].v = v;
  e[tot].nxt = h[u];
  h[u] = tot;
  return true;
}
bool dfs(int np, int lst) {
  sze[np] = 1;
  for (int i = h[np]; i; i = e[i].nxt) {
    if (e[i].v == lst) continue;
    dfs(e[i].v, np);
    sze[np] += sze[e[i].v];
  }
  f[np] = sq(sze[np]);
  top = tp = 0;
  if (sze[np] == 1) return true;
  for (int i = h[np]; i; i = e[i].nxt) {
    if (e[i].v == lst) continue;
    f[np] = Min(f[np], f[e[i].v] + sq(sze[np] - sze[e[i].v]));
    q[++tp] = e[i].v;
  }
  ans = Min(ans, f[np] + sq(n - sze[np]));
  sort(q + 1, q + tp + 1, cmp);
  st[++top] = q[1];
  for (int i = 2; i <= tp; i++) {
    ans = Min(ans, f[st[top]] + f[q[i]] + sq(n - sze[q[i]] - sze[st[top]]));
    while (top > 1 && k(st[top - 1], st[top]) < k(st[top], q[i])) top--;
    st[++top] = q[i];
    while (top > 1 && k(st[top - 1], st[top]) <= 2.0 * sze[q[i]]) top--;
  }
  return true;
}
int main() {
  n = read();
  for (int i = 1; i < n; i++) {
    u = read();
    v = read();
    add(u, v);
    add(v, u);
  }
  dfs(1, 0);
  printf("%lld", 1LL * n * (n - 1) / 2 + (1LL * n * n - ans) / 2);
}
