#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1000000000")
using namespace std;
const int maxn = (int)5e5 + 10;
vector<int> ed[maxn];
long long sz[maxn];
long long dp[maxn];
int n;
bool cmp(int a, int b) { return sz[a] < sz[b]; }
struct vt {
  long long x, y;
  vt() {}
  vt(long long x, long long y) : x(x), y(y) {}
};
vt operator-(vt a, vt b) {
  a.x -= b.x;
  a.y -= b.y;
  return a;
}
vt operator+(vt a, vt b) {
  a.x += b.x;
  a.y += b.y;
  return a;
}
long long operator*(vt a, vt b) { return a.x * b.x + a.y * b.y; }
long long operator%(vt a, vt b) { return a.x * b.y - a.y * b.x; }
vector<vt> f;
void add(long long x, long long y) {
  vt a = vt(x, y);
  int len = (int)f.size();
  if (!f.empty() && f.back().x > x) {
    throw 1;
  }
  while (len >= 2 && (a - f[len - 2]) % (f[len - 1] - f[len - 2]) >= 0) {
    f.pop_back();
    len--;
  }
  f.push_back(a);
}
long long get_best(long long x, long long y) {
  vt a = vt(x, y);
  int l = 0;
  int r = (int)f.size() - 1;
  while (l != r) {
    int m = (l + r) >> 1;
    long long v1 = a * f[m];
    long long v2 = a * f[m + 1];
    if (v2 <= v1) {
      l = m + 1;
    } else {
      r = m;
    }
  }
  return a * f[l];
}
long long go(int v, int p) {
  long long ans = (long long)1e18;
  sz[v] = 1;
  dp[v] = (long long)1e18;
  for (int i = 0; i < (int)ed[v].size(); i++) {
    int u = ed[v][i];
    if (u == p) {
      continue;
    }
    ans = min(ans, go(u, v));
    sz[v] += sz[u];
  }
  f.clear();
  sort(ed[v].begin(), ed[v].end(), cmp);
  for (int i = 0; i < (int)ed[v].size(); i++) {
    int u = ed[v][i];
    if (u == p) {
      continue;
    }
    long long res = dp[u] + (long long)(n - sz[u]) * (n - sz[u] - 1) / 2;
    ans = min(ans, res);
    if (!f.empty()) {
      long long g = get_best(sz[u], 1);
      ans = min(ans, g + (long long)sz[u] * (sz[u] + 1) / 2 -
                         (long long)sz[u] * n + dp[u]);
    }
    add(sz[u], res);
    long long cur =
        dp[u] + (long long)(sz[v] - sz[u] - 1) * (sz[v] - sz[u]) / 2;
    dp[v] = min(dp[v], cur);
  }
  dp[v] = min(dp[v], (long long)sz[v] * (sz[v] - 1) / 2);
  return ans;
}
int main() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    ed[x].push_back(y);
    ed[y].push_back(x);
  }
  long long ans = (long long)n * (n - 1) - go(1, -1);
  cout << ans << endl;
  return 0;
}
