#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long num = 0ll;
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch))
    num = (num << 3ll) + (num << 1ll) + (ch ^ 48), ch = getchar();
  return num;
}
const int N = 5e5 + 7, M = 5e5 + 7;
int c[N], len, q[N];
struct s {
  int y, nxt;
} b[M << 1];
inline void add(int x, int y) { b[++len] = (s){y, c[x]}, c[x] = len; }
long long ans = (long long)N * (long long)N, del[N], siz[N], n3, n;
bool vis[N];
inline long long X(int i) { return n3 - 2ll * siz[i]; }
inline long long K(int i) { return siz[i]; }
inline long long Y(int i) {
  return siz[i] * siz[i] - n3 * siz[i] + 2ll * del[i];
}
inline long long B(int i) {
  return (long long)n * (long long)(n - 1) + siz[i] * siz[i] + 2ll * del[i];
}
inline double slope(int x, int y) {
  return X(x) == X(y) ? (Y(x) > Y(y) ? 1e18 : -1e18)
                      : ((double)(Y(x) - Y(y)) / (double)(X(x) - X(y)));
}
inline bool cmp(int x, int y) { return K(x) < K(y); }
inline void dfs1(int x) {
  vis[x] = true;
  siz[x] = 1ll;
  for (int i = c[x]; i; i = b[i].nxt) {
    int y = b[i].y;
    if (vis[y]) continue;
    dfs1(y);
    siz[x] += siz[y];
  }
}
inline void dp(int x) {
  vis[x] = true;
  del[x] = (long long)N * (long long)N;
  vector<int> son;
  son.clear();
  if (siz[x] == 1) del[x] = 0ll;
  for (int i = c[x]; i; i = b[i].nxt) {
    int y = b[i].y;
    if (vis[y]) continue;
    dp(y);
    son.push_back(y);
    del[x] =
        min(del[x], (siz[x] - siz[y]) * (siz[x] - siz[y] - 1ll) / 2ll + del[y]);
  }
  ans = min(ans, ((long long)n - siz[x]) * ((long long)n - siz[x] + 1ll) / 2ll +
                     del[x]);
  if (son.size() <= 1) return;
  sort(son.begin(), son.end(), cmp);
  int h = 1, e = 1;
  q[1] = son[0];
  for (register int j = 1; j < son.size(); j++) {
    int i = son[j];
    while (e - h >= 1 && slope(q[h], q[h + 1]) >= K(i)) q[h++] = 0;
    ans = min(ans, (B(i) - K(i) * X(q[h]) + Y(q[h])) / 2ll);
    while (e - h >= 1 && slope(q[e - 1], q[e]) <= slope(q[e], i)) q[e--] = 0;
    q[++e] = i;
  }
  for (register int i = h; i <= e; i++) q[i] = 0;
}
int main() {
  n = read();
  n3 = 2ll * n - 1ll;
  for (register int i = 1; i < n; i++) {
    int x = read(), y = read();
    add(x, y);
    add(y, x);
  }
  dfs1(1);
  memset(vis, false, sizeof vis);
  dp(1);
  printf("%lld\n", (long long)n * (n - 1) - ans);
  return 0;
}
