#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target( \
    "avx,avx2,fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
long long MOD = 1e18;
const int N = 510000;
vector<long long> gr[N];
long long dp[N];
long long sz[N];
long long n;
long long kv(long long a) { return a * a; }
long long dfs(long long v, long long pr) {
  sz[v] = 1;
  long long ans = MOD;
  dp[v] = MOD;
  for (auto i : gr[v]) {
    if (i != pr) {
      ans = min(dfs(i, v), ans);
      sz[v] += sz[i];
    }
  }
  if (gr[v].size() == 1) {
    dp[v] = 1;
    return 2 * kv(n);
  }
  unordered_map<long long, long long> keko;
  for (auto i : gr[v]) {
    if (i != pr) {
      dp[v] = min(dp[v], kv(sz[v] - sz[i]) + dp[i]);
      if (keko.count(sz[i])) {
        ans = min(ans, keko[sz[i]] + dp[i] + kv(n - 2 * sz[i]));
        keko[sz[i]] = min(keko[sz[i]], dp[i]);
      } else {
        keko[sz[i]] = dp[i];
      }
    }
  }
  for (auto i : keko) {
    for (auto j : keko) {
      if (j.first != i.first)
        ans = min(ans, i.second + j.second + kv(n - i.first - j.first));
    }
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0),
      cout << fixed << setprecision(20);
  cin >> n;
  long long start = -1;
  for (int i = 0; i < n - 1; i++) {
    long long u, v;
    cin >> u >> v;
    u--, v--;
    gr[u].push_back(v);
    gr[v].push_back(u);
    if (gr[u].size() > 1) {
      start = u;
    }
    if (gr[v].size() > 1) {
      start = v;
    }
  }
  if (start == -1) {
    cout << 2;
    return 0;
  }
  cout << (2 * kv(n) - n - dfs(start, start)) / 2;
}
