#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 100;
const long long inF = 1e15;
long long n, sz[N], dp[N];
long long mini = inF;
vector<int> nei[N];
long long c(long long x) { return (x * (x - 1)) >> 1; }
void dfs(int v, int par = -1) {
  sz[v] = 1;
  unordered_map<int, long long> help1, help2;
  for (int u : nei[v])
    if (u != par) {
      dfs(u, v);
      sz[v] += sz[u];
      if (help1.find(sz[u]) == help1.end())
        help1[sz[u]] = dp[u];
      else {
        if (help2.find(sz[u]) == help2.end())
          help2[sz[u]] = dp[u];
        else {
          help2[sz[u]] = min(help2[sz[u]], dp[u]);
          if (help2[sz[u]] < help1[sz[u]]) swap(help1[sz[u]], help2[sz[u]]);
        }
      }
    }
  dp[v] = c(sz[v]);
  for (int u : nei[v])
    if (u != par) dp[v] = min(dp[v], dp[u] + c(sz[v] - sz[u]));
  vector<pair<int, long long> > vec;
  for (pair<int, long long> p : help1) vec.push_back(p);
  for (pair<int, long long> p : help2) vec.push_back(p);
  for (int i = 0; i < vec.size(); i++)
    for (int j = i + 1; j < vec.size(); j++)
      mini = min(mini, vec[i].second + vec[j].second +
                           c(n - vec[i].first - vec[j].first));
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  srand(time(0));
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    nei[--u].push_back(--v);
    nei[v].push_back(u);
  }
  int X = 0;
  for (int i = 0; i < n; i++)
    if (nei[i].size() > nei[X].size()) X = i;
  if (n == 2)
    cout << 2;
  else {
    dfs(X);
    cout << 1LL * n * (n - 1) - mini;
  }
  return 0;
}
