#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 7;
long long n, a, b, ans, rt = 1, tot, dp[N];
long long head[N], to[N << 1], nxt[N << 1], siz[N];
void add(int a, int b) {
  nxt[++tot] = head[a];
  head[a] = tot;
  to[tot] = b;
}
void dfs1(int u, int fa) {
  siz[u] = 1;
  for (int i = head[u]; i; i = nxt[i]) {
    int v = to[i];
    if (v == fa) continue;
    dfs1(v, u);
    siz[u] += siz[v];
  }
}
void dfs2(int u, int fa) {
  for (int i = head[u]; i; i = nxt[i]) {
    int v = to[i];
    if (v == fa) continue;
    dp[v] = dp[u] + siz[v] * (siz[u] - siz[v]);
    dfs2(v, u);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &a, &b);
    add(a, b);
    add(b, a);
  }
  dfs1(1, -1);
  dfs2(1, -1);
  for (int i = 2; i <= n; i++)
    if (dp[i] > ans) {
      ans = dp[i];
      rt = i;
    }
  dfs1(rt, -1);
  dp[rt] = 0;
  dfs2(rt, -1);
  ans = 0;
  for (int i = 1; i <= n; i++) ans = max(ans, dp[i]);
  printf("%lld\n", ans + (n * (n - 1) / 2));
}
