#include <bits/stdc++.h>
using namespace std;
void read(long long &x) {
  x = 0;
  long long f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -f;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  x *= f;
}
void print(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (!x) return;
  print(x / 10), putchar(x % 10 + 48);
}
void write(long long x) {
  if (!x)
    putchar('0');
  else
    print(x);
  putchar('\n');
}
const long long maxn = 1e6 + 10;
const long long inf = 1e18;
const double eps = 1e-8;
const long long mod = 1e9 + 7;
long long f[maxn], sz[maxn], n, head[maxn], tot, mn[maxn], ans = inf;
struct edge {
  long long to, nxt;
} e[maxn << 1];
void ins(long long u, long long v) {
  e[++tot] = (edge){v, head[u]}, head[u] = tot;
}
void dfs(long long x, long long fa) {
  sz[x] = 1;
  for (long long i = head[x]; i; i = e[i].nxt)
    if (e[i].to != fa) dfs(e[i].to, x), sz[x] += sz[e[i].to];
}
pair<long long, long long> sta[maxn], res[maxn];
long long top, cnt;
void get(pair<long long, long long> a, pair<long long, long long> b) {
  ans = min(ans, ((n - a.first - b.first) * (n - a.first - b.first)) +
                     a.second + b.second);
}
void dfs2(long long x, long long fa) {
  f[x] = 1;
  for (long long i = head[x]; i; i = e[i].nxt)
    if (e[i].to != fa) f[x] = inf, dfs2(e[i].to, x);
  top = cnt = 0;
  for (long long v, i = head[x]; i; i = e[i].nxt)
    if ((v = e[i].to) != fa) {
      sta[++top] = make_pair(sz[v], f[v]);
      f[x] = min(f[x], ((sz[x] - sz[v]) * (sz[x] - sz[v])) + f[v]);
    }
  sort(sta + 1, sta + top + 1);
  for (long long i = 1; i <= top; i++)
    if (sta[i].first != sta[i - 1].first) {
      if (sta[i].first == sta[i + 1].first) get(sta[i], sta[i + 1]);
      res[++cnt] = sta[i];
    }
  for (long long i = 1; i <= cnt; i++)
    for (long long j = i + 1; j <= cnt; j++) get(res[i], res[j]);
}
signed main() {
  read(n);
  for (long long i = 1, x, y; i < n; i++)
    read(x), read(y), ins(x, y), ins(y, x);
  dfs(1, 0);
  dfs2(1, 0);
  ans = min(ans, f[1]);
  write(n * (n - 1) / 2 + (n * n - ans) / 2);
  return 0;
}
