#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll getrnd(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rng); }
template <typename T1, typename T2>
inline bool relax(T1& a, const T2& b) {
  return a > b ? a = b, true : false;
}
template <typename T1, typename T2>
inline bool strain(T1& a, const T2& b) {
  return a < b ? a = b, true : false;
}
const int N = 5e5 + 5;
const ll INF = 1e18;
ll n, dp[N], sz[N], ans = INF;
vector<int> graph[N];
struct line {
  ll k, b;
  ll eval(ll x) { return k * x + b; }
  ll inter(const line& oth) { return (b - oth.b) / (oth.k - k); }
};
void dfs(int v, int p) {
  sz[v] = 1;
  for (int to : graph[v]) {
    if (to == p) continue;
    dfs(to, v);
    sz[v] += sz[to];
  }
  sort(graph[v].begin(), graph[v].end(),
       [&](int x, int y) { return sz[x] < sz[y]; });
  if (graph[v].size() == 1) {
    dp[v] = 1;
    return;
  }
  dp[v] = INF;
  deque<line> st;
  for (int to : graph[v]) {
    if (to == p) continue;
    relax(dp[v], dp[to] + ((sz[v] - sz[to]) * (sz[v] - sz[to])));
    ll x = sz[to];
    line cur{2 * sz[to], ((sz[to]) * (sz[to])) - 2 * n * sz[to] + dp[to]};
    while (st.size() >= 2 && st[0].eval(x) >= st[1].eval(x)) st.pop_front();
    if (!st.empty())
      relax(ans, st[0].eval(x) + ((n) * (n)) + ((sz[to]) * (sz[to])) -
                     2 * n * sz[to] + dp[to]);
    while (!st.empty() && st[0].k == cur.k && st[0].b > cur.b) st.pop_front();
    if (!st.empty() && st[0].k == cur.k) continue;
    while (st.size() >= 2 && st[0].inter(cur) >= st[0].inter(st[1]))
      st.pop_front();
    st.push_front(cur);
  }
}
void solve() {
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    int x, y;
    cin >> x >> y;
    --x;
    --y;
    graph[x].emplace_back(y);
    graph[y].emplace_back(x);
  }
  if (n == 2) {
    cout << "2\n";
    return;
  }
  for (int i = 0; i < n; ++i) {
    if (graph[i].size() > 1) {
      dfs(i, i);
      break;
    }
  }
  cout << (2 * ((n) * (n)) - ans - n) / 2 << '\n';
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int t = 1;
  while (t--) solve();
  return 0;
}
