#include <bits/stdc++.h>
using namespace std;
mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
template <typename T>
void chkmax(T& x, T y) {
  if (x < y) x = y;
}
template <typename T>
void chkmin(T& x, T y) {
  if (x > y) x = y;
}
inline int read() {
  int x = 0;
  char c = getchar();
  while (c < 48) c = getchar();
  while (c > 47) x = x * 10 + (c ^ 48), c = getchar();
  return x;
}
const int maxn = 5e5 + 10;
int n;
vector<int> E[maxn];
int sz[maxn];
long long as, chk[maxn][2], dp1[maxn][2], dp2[maxn];
long long sqr(long long x) { return x * x; }
void dfs1(int u, int f) {
  sz[u] = 1;
  for (int v : E[u])
    if (v != f) {
      dfs1(v, u), sz[u] += sz[v];
    }
  dp1[u][0] = dp1[u][1] = 1e18;
  if ((int)E[u].size() == 1) return dp1[u][0] = 1, void();
  for (int v : E[u])
    if (v != f) {
      long long tp = dp1[v][0] + sqr(sz[u] - sz[v]);
      if (dp1[u][0] > tp)
        dp1[u][1] = dp1[u][0], dp1[u][0] = tp, chk[u][1] = chk[u][0],
        chk[u][0] = v;
      else if (dp1[u][1] > tp)
        dp1[u][1] = tp, chk[u][1] = v;
    }
  int v0 = chk[u][0], v1 = chk[u][1];
  if (v1) chkmin(as, dp1[v0][0] + dp1[v1][0] + sqr(n - sz[v0] - sz[v1]));
}
void dfs2(int u, int f, long long val) {
  chkmin(as, dp1[u][0] + val);
  for (int v : E[u])
    if (v != f) {
      long long tp = 1e18;
      for (int t = (0), tend = (1); t <= tend; ++t) {
        int v0 = chk[u][t];
        if (v0 == v || !v0) continue;
        tp =
            min(val + sqr(sz[u] - sz[v]), dp1[v0][0] + sqr(n - sz[v0] - sz[v]));
        break;
      }
      if (tp > 1e17) tp = sqr(n - sz[v]);
      dfs2(v, u, tp);
    }
}
void solve() {
  cin >> n;
  for (int i = (2), iend = (n); i <= iend; ++i) {
    int u = read(), v = read();
    E[u].push_back(v), E[v].push_back(u);
  }
  as = 1e18;
  dfs1(1, 0), dfs2(1, 0, 1e18);
  cout << 1ll * n * (n - 1) - (as - n) / 2 << endl;
}
signed main() {
  solve();
  return 0;
}
