#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
struct node {
  int to, next;
} e[N * 2];
int cnt, head[N];
void add(int x, int y) {
  e[cnt].to = y;
  e[cnt].next = head[x];
  head[x] = cnt++;
}
long long siz[N];
void dfs(int x, int fa) {
  siz[x] = 1;
  for (int i = head[x]; ~i; i = e[i].next) {
    int ne = e[i].to;
    if (ne == fa) continue;
    dfs(ne, x);
    siz[x] += siz[ne];
  }
}
long long dp[N], p;
void f_ans(int x, int fa) {
  for (int i = head[x]; ~i; i = e[i].next) {
    int ne = e[i].to;
    if (ne == fa) continue;
    dp[ne] = dp[x] + (siz[x] - siz[ne]) * siz[ne];
    if (dp[ne] > dp[p]) p = ne;
    f_ans(ne, x);
  }
}
int main() {
  memset(head, -1, sizeof(head));
  long long n;
  int x, y;
  scanf("%lld", &n);
  for (int i = 1; i < n; i++) scanf("%d%d", &x, &y), add(x, y), add(y, x);
  dfs(1, 0);
  f_ans(1, 0);
  memset(dp, 0, sizeof(dp));
  dfs(p, 0);
  f_ans(p, 0);
  printf("%lld\n", n * (n - 1) / 2 + dp[p]);
  return 0;
}
