#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10;
vector<int> e[N];
int size[N];
long long s[N];
inline void dfs0(int x, int fa) {
  size[x] = 1;
  for (auto &y : e[x]) {
    if (y == fa) continue;
    dfs0(y, x);
    size[x] += size[y];
  }
}
inline void dfs(int x, int fa) {
  for (auto &y : e[x]) {
    if (y == fa) continue;
    s[y] = s[x] + (long long)(size[x] - size[y]) * size[y];
    dfs(y, x);
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    e[x].push_back(y);
    e[y].push_back(x);
  }
  s[1] = (long long)n * (n - 1) / 2;
  dfs0(1, 0), dfs(1, 0);
  int x = 1;
  for (int i = 2; i <= n; i++)
    if (s[x] < s[i]) x = i;
  s[x] = (long long)n * (n - 1) / 2;
  dfs0(x, 0), dfs(x, 0);
  for (int i = 1; i <= n; i++)
    if (s[x] < s[i]) x = i;
  printf("%I64d\n", s[x]);
  return 0;
}
