#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 100;
long long dp[N];
int son[N];
vector<int> G[N];
int n;
long long mndmg = 1e18;
struct node {
  long long a, b;
  int cnt;
  void init() { cnt = 0; }
  void add(long long x) {
    cnt++;
    if (cnt == 1)
      a = x;
    else if (cnt == 2) {
      if (x > a)
        b = x;
      else
        b = a, a = x;
    } else {
      if (x < a)
        b = a, a = x;
      else if (x < b)
        b = x;
    }
  }
};
void dfs(int x, int f) {
  son[x] = 1;
  for (int i = 0; i < G[x].size(); i++) {
    int v = G[x][i];
    if (v == f) continue;
    dfs(v, x);
    son[x] += son[v];
  }
}
void dfsdp(int x, int f) {
  if (son[x] == 1) {
    dp[x] = 0;
    return;
  }
  map<int, node> mp;
  long long mn = 1e18;
  for (int i = 0; i < G[x].size(); i++) {
    int v = G[x][i];
    if (v == f) continue;
    dfsdp(v, x);
    if (mp.find(son[v]) != mp.end())
      mp[son[v]].add(dp[v]);
    else {
      node tmp;
      tmp.init();
      tmp.add(dp[v]);
      mp[son[v]] = tmp;
    }
    long long cnt = 1LL * (son[x] - son[v]) * (son[x] - son[v] - 1) / 2;
    mn = min(mn, cnt + dp[v]);
    mndmg = min(mndmg, dp[v] + 1LL * (n - son[v]) * (n - son[v] - 1) / 2);
  }
  vector<pair<int, long long> > vec;
  for (auto iter = mp.begin(); iter != mp.end(); iter++) {
    vec.push_back({iter->first, iter->second.a});
    if (iter->second.cnt >= 2) {
      int tmp = n - 2 * iter->first;
      mndmg = min(mndmg,
                  1ll * tmp * (tmp - 1) / 2 + iter->second.a + iter->second.b);
    }
  }
  if (vec.size() > 1) {
    for (int i = 0; i < vec.size(); i++) {
      for (int j = i + 1; j < vec.size(); j++) {
        int tmp = n - vec[i].first - vec[j].first;
        mndmg = min(mndmg,
                    1ll * tmp * (tmp - 1) / 2 + vec[i].second + vec[j].second);
      }
    }
  }
  dp[x] = mn;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    G[a].push_back(b);
    G[b].push_back(a);
  }
  if (n == 2) {
    puts("2");
    return 0;
  }
  dfs(1, -1);
  memset(dp, 0x3f, sizeof(dp));
  dfsdp(1, -1);
  if (mndmg == 1e18) {
    cout << mndmg << endl;
  }
  cout << 1ll * n * (n - 1) - mndmg << endl;
  return 0;
}
