#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
void warp() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
}
long long sq(long long a) { return a * a; }
long long n;
double cross(pair<long long, long long> a, pair<long long, long long> b) {
  return -1.0 * (double)(b.first - b.second) / (double)(a.first - a.second);
}
void push(vector<pair<long long, long long> > &st,
          pair<long long, long long> n) {
  while (st.size() && st.back().first == n.first) {
    if (st.back().second <= n.second) return;
    st.pop_back();
  }
  while (st.size() > 1) {
    double prev = cross(st[st.size() - 2], st[st.size() - 1]),
           cur = cross(st.back(), n);
    if (cur <= prev)
      st.pop_back();
    else
      break;
  }
  st.push_back(n);
}
long long get(vector<pair<long long, long long> > &st, long long x) {
  if (st.size() == 0) return INF;
  if (st.size() == 1) return st[0].first * x + st[0].second;
  double temp = cross(st[st.size() - 2], st[st.size() - 1]);
  if (x >= temp) return st.back().first * x + st.back().second;
  long long l = 0, r = st.size() - 1;
  while (r - l > 1) {
    long long m = (l + r) / 2;
    temp = cross(st[m - 1], st[m]);
    if (x >= temp)
      l = m;
    else
      r = m;
  }
  return st[l].first * x + st[l].second;
}
void print(vector<pair<long long, long long> > &st) {
  cout << st.size() << endl;
  for (long long i = 0; i < st.size(); i++) {
    cout << st[i].first << " " << st[i].second << endl;
  }
}
void dfs(long long v, long long prev, vector<vector<long long> > &g,
         vector<long long> &sz, vector<long long> &dp, vector<long long> &ans) {
  sz[v] = 1;
  dp[v] = INF;
  ans[v] = INF;
  if (g[v].size() == 1 && prev != -1) {
    dp[v] = 1;
  }
  for (long long i = 0; i < g[v].size(); i++) {
    long long u = g[v][i];
    if (u == prev) continue;
    dfs(u, v, g, sz, dp, ans);
    ans[v] = min(ans[v], ans[u]);
    sz[v] += sz[u];
  }
  for (long long i = 0; i < g[v].size(); i++) {
    long long u = g[v][i];
    if (u == prev) continue;
    dp[v] = min(dp[v], dp[u] + sq(sz[v] - sz[u]));
  }
  vector<pair<long long, long long> > st;
  vector<pair<long long, long long> > temp;
  for (long long i = 0; i < g[v].size(); i++) {
    long long u = g[v][i];
    if (u == prev) continue;
    temp.push_back(make_pair(sz[u], u));
  }
  sort(temp.begin(), temp.end());
  reverse(temp.begin(), temp.end());
  for (long long i = 0; i < temp.size(); i++) {
    long long u = temp[i].second;
    long long k = n - sz[u];
    long long p = dp[u];
    ans[v] = min(ans[v], sq(k) + p + get(st, -2 * k));
    push(st, make_pair(sz[u], sq(sz[u]) + dp[u]));
  }
}
long long calc(long long v, long long prev, vector<vector<long long> > &g,
               vector<long long> &sz) {
  long long ans = sz[v] * (n - sz[v]);
  for (long long i = 0; i < g[v].size(); i++) {
    long long u = g[v][i];
    if (u == prev) continue;
    ans = max(ans, calc(u, v, g, sz));
  }
  return ans;
}
long long solve(vector<vector<long long> > g) {
  vector<long long> sz(n);
  vector<long long> ans(n);
  vector<long long> dp(n);
  long long root = 0;
  while (g[root].size() == 1) root++;
  long long base = (n * (n - 1)) / 2;
  dfs(root, -1, g, sz, dp, ans);
  for (long long i = 0; i < n; i++) {
  }
  return base + (sq(n) - ans[root]) / 2;
}
bool check(set<pair<long long, long long> > &a, pair<long long, long long> b) {
  return (a.find(b) != a.end());
}
void dumbDfs(long long v, long long prev, vector<vector<long long> > &g,
             vector<long long> &sz, vector<long long> &anc,
             vector<long long> &h) {
  anc[v] = prev;
  sz[v] = 1;
  for (long long i = 0; i < g[v].size(); i++) {
    long long u = g[v][i];
    if (u == prev) continue;
    h[u] = h[v] + 1;
    dumbDfs(u, v, g, sz, anc, h);
    sz[v] += sz[u];
  }
}
long long dumbSolve(vector<vector<long long> > g) {
  vector<long long> anc(n);
  vector<long long> sz(n);
  vector<long long> h(n);
  long long root = 0;
  while (g[root].size() == 1) root++;
  dumbDfs(root, -1, g, sz, anc, h);
  long long base = n * (n - 1) / 2;
  long long ans = INF;
  for (long long v = 0; v < n; v++) {
    if (g[v].size() > 1) continue;
    for (long long u = v + 1; u < n; u++) {
      if (g[u].size() > 1) continue;
      long long l = v, r = u;
      while (h[l] > h[r]) l = anc[l];
      while (h[r] > h[l]) r = anc[r];
      while (l != r) l = anc[l], r = anc[r];
      long long top = l;
      l = v, r = u;
      long long s = 0;
      s += sq(sz[l]);
      s += sq(sz[r]);
      while (anc[l] != top) s += sq(sz[anc[l]] - sz[l]), l = anc[l];
      while (anc[r] != top) s += sq(sz[anc[r]] - sz[r]), r = anc[r];
      s += sq(n - sz[l] - sz[r]);
      ans = min(ans, s);
    }
  }
  return base + (sq(n) - ans) / 2;
}
signed main() {
  warp();
  cin >> n;
  if (n == 2) {
    cout << 2 << endl;
    return 0;
  }
  vector<vector<long long> > g(n);
  for (long long i = 0; i < n - 1; i++) {
    long long u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  cout << solve(g) << endl;
  return 0;
}
