#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 10;
long long dp[maxn], n, Ans, sz[maxn];
vector<int> v[maxn], son[maxn], ch[maxn];
int I, J;
long long Ra(int i) { return 1LL * i * (i - 1) / 2; }
bool amx(int i, int j) {
  if (sz[i] != sz[j]) return sz[i] < sz[j];
  return dp[i] < dp[j];
}
void dfs(int i, int j) {
  sz[i] = 1;
  for (int y = 0; y < v[i].size(); y++) {
    int x = v[i][y];
    if (j - x) {
      dfs(x, i);
      sz[i] += sz[x];
    }
  }
  dp[i] = Ra(sz[i]);
  for (int y = 0; y < v[i].size(); y++) {
    int x = v[i][y];
    if (j - x) {
      dp[i] = min(dp[i], Ra(sz[i] - sz[x]) + dp[x]);
      son[i].push_back(x);
      Ans = min(Ans, dp[x] + Ra(n - sz[x]));
    }
  }
  son[i].push_back(0);
  sort(son[i].begin(), son[i].end(), amx);
  for (int y = 1; y < son[i].size(); y++) {
    if (sz[son[i][y]] != sz[son[i][y - 1]]) ch[i].push_back(son[i][y]);
    if (y != 1)
      Ans = min(Ans, dp[son[i][y]] + dp[son[i][y - 1]] +
                         Ra(n - sz[son[i][y]] - sz[son[i][y - 1]]));
  }
  for (int y = 0; y < ch[i].size(); y++)
    for (int x = y + 1; x < ch[i].size(); x++)
      Ans = min(Ans, dp[ch[i][y]] + dp[ch[i][x]] +
                         Ra(n - (sz[ch[i][y]] + sz[ch[i][x]])));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  scanf("%d", &n);
  for (int y = 1; y < n; y++) {
    scanf("%d", &I);
    scanf("%d", &J);
    v[I].push_back(J);
    v[J].push_back(I);
  }
  Ans = 1LL * 1e15;
  dfs(1, 0);
  Ans *= -1;
  Ans += 1LL * (n * (n - 1));
  cout << Ans;
}
