#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x) {
  long long f = 0, c = getchar();
  x = 0;
  while (!isdigit(c)) f |= c == 45, c = getchar();
  while (isdigit(c)) x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  if (f) x = -x;
}
template <typename T, typename... Args>
inline void read(T &x, Args &...args) {
  read(x);
  read(args...);
}
namespace run {
const long long maxn = 5e5 + 10;
const long long inf = 1000000000000000000;
long long n, m, ans = inf;
long long f[maxn], siz[maxn], stk[maxn], q[maxn];
struct Edge {
  long long nxt, to;
} edge[maxn << 1];
long long begn[maxn], e;
inline void add(long long x, long long y) {
  edge[++e] = (Edge){begn[x], y};
  begn[x] = e;
  return;
}
inline bool cmp(long long u, long long v) { return siz[u] < siz[v]; }
inline long long X(long long x) { return siz[x]; }
inline long long Y(long long x) { return f[x] + siz[x] * siz[x]; }
inline double slope(long long u, long long v) {
  if (X(u) == X(v)) return Y(u) > Y(v) ? inf : -inf;
  return 1.0 * (Y(u) - Y(v)) / (X(u) - X(v));
}
inline void dfs(long long x, long long fa) {
  long long top = 0, head = 1, tail = 0;
  siz[x] = 1;
  for (register long long i = begn[x]; i; i = edge[i].nxt) {
    long long y = edge[i].to;
    if (y ^ fa) {
      dfs(y, x);
      siz[x] += siz[y];
    }
  }
  f[x] = siz[x] * siz[x];
  if (siz[x] == 1) return;
  for (register long long i = begn[x]; i; i = edge[i].nxt) {
    long long y = edge[i].to;
    if (y ^ fa) {
      f[x] = min(f[x], f[y] + (siz[x] - siz[y]) * (siz[x] - siz[y]));
      stk[++top] = y;
    }
  }
  ans = min(ans, f[x] + (n - siz[x]) * (n - siz[x]));
  sort(stk + 1, stk + 1 + top, cmp);
  q[++tail] = stk[1];
  for (register long long i = 2; i <= top; ++i) {
    while (head < tail && slope(q[head + 1], q[head]) <= 2 * (n - siz[stk[i]]))
      ++head;
    ans = min(ans, f[stk[i]] + f[q[head]] +
                       (n - siz[stk[i]] - siz[q[head]]) *
                           (n - siz[stk[i]] - siz[q[head]]));
    while (head < tail &&
           slope(stk[i], q[tail - 1]) <= slope(q[tail], q[tail - 1]))
      --tail;
    q[++tail] = stk[i];
  }
  return;
}
inline long long main() {
  read(n);
  for (register long long i = 1, x, y; i < n; ++i) {
    read(x, y);
    add(x, y);
    add(y, x);
  }
  dfs(1, 0);
  printf("%lld\n", n * (n - 1) / 2 + (n * n - ans) / 2);
  return 0;
}
}  // namespace run
int main() { return run ::main(); }
