#include <bits/stdc++.h>
const int maxn = 5e5 + 1;
template <class T>
inline void read(T &x) {
  T f = 1;
  x = 0;
  char s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = (x * 10) + (s & 15);
    s = getchar();
  }
  x *= f;
}
struct Edge {
  long long u, v;
} e[maxn << 1];
long long head[maxn], ecnt;
inline void addedge(long long u, long long v) {
  e[++ecnt].v = v;
  e[ecnt].u = head[u];
  head[u] = ecnt;
}
inline void add(long long u, long long v) {
  addedge(u, v);
  addedge(v, u);
}
long long siz[maxn], ans, n, a, b, root, g[maxn];
inline void dfs1(long long x, long long fa) {
  siz[x] = 1;
  for (long long i = head[x], v; i && (v = e[i].v); i = e[i].u) {
    if (v == fa) continue;
    dfs1(v, x);
    siz[x] += siz[v];
  }
}
inline void dfs2(long long x, long long fa) {
  for (long long i = head[x], v; i && (v = e[i].v); i = e[i].u) {
    if (v == fa) continue;
    g[v] = g[x] + (siz[x] - siz[v]) * siz[v];
    dfs2(v, x);
  }
}
signed main() {
  read(n);
  for (long long i = 1; i <= n - 1; i++) read(a), read(b), add(a, b);
  dfs1(1, 0);
  root = 1;
  g[1] = (n * (n - 1)) / 2;
  dfs2(1, 0);
  for (long long i = 1; i <= n; i++)
    if (g[root] < g[i]) root = i;
  dfs1(root, 0);
  g[root] = (n * (n - 1)) / 2;
  dfs2(root, 0);
  for (long long i = 1; i <= n; i++) ans = std::max(ans, g[i]);
  printf("%lld\n", ans);
}
