#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void chkmax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
inline void chkmin(T &a, T b) {
  if (a > b) a = b;
}
inline int read() {
  int sum = 0, p = 1;
  char ch = getchar();
  while (!(('0' <= ch && ch <= '9') || ch == '-')) ch = getchar();
  if (ch == '-') p = -1, ch = getchar();
  while ('0' <= ch && ch <= '9') sum = sum * 10 + ch - 48, ch = getchar();
  return sum * p;
}
const int maxn = 5e5 + 20;
struct node {
  int v, next;
};
node e[maxn << 1];
int cnt, start[maxn];
inline void addedge(int u, int v) {
  e[++cnt] = (node){v, start[u]};
  start[u] = cnt;
}
int n;
inline void init() {
  n = read();
  for (int i = (1), _end_ = (n - 1); i <= _end_; i++) {
    int u = read(), v = read();
    addedge(u, v);
    addedge(v, u);
  }
}
int sz[maxn];
void get_sz(int u, int fa) {
  sz[u] = 1;
  for (int i = start[(u)]; i; i = e[i].next)
    if (e[i].v != fa) get_sz(e[i].v, u), sz[u] += sz[e[i].v];
}
long long ans[maxn];
void dfs(int u, int fa) {
  for (int i = start[(u)]; i; i = e[i].next) {
    int v = e[i].v;
    if (v == fa) continue;
    ans[v] = ans[u] + (long long)(sz[u] - sz[v]) * sz[v];
    dfs(v, u);
  }
}
inline void doing() {
  get_sz(1, 0);
  ans[1] = (long long)n * (n - 1) >> 1;
  dfs(1, 0);
  int u = 2;
  for (int i = (3), _end_ = (n); i <= _end_; i++)
    if (ans[u] < ans[i]) {
      u = i;
    }
  get_sz(u, 0);
  ans[u] = (long long)n * (n - 1) >> 1;
  dfs(u, 0);
  long long t = 0;
  for (int i = (1), _end_ = (n); i <= _end_; i++) chkmax(t, ans[i]);
  printf("%lld\n", t);
}
int main() {
  init();
  doing();
  return 0;
}
