#include <bits/stdc++.h>
using namespace std;
struct Tree {
  struct Edge {
    long long dest, weight;
    int id;
    Edge(long long _dest = -1, long long _weight = 1, int _id = 0) {
      dest = _dest;
      weight = _weight;
      id = _id;
    }
  };
  int n, root;
  vector<vector<Edge>> adj;
  vector<int> subtreeCount, parent, startTime, finishTime, nodeStartingAt;
  vector<long long> dist;
  long long INF = (long long)1e15;
  Tree(int _nodes = 0, int _root = 1) {
    n = _nodes;
    adj.resize(n + 1);
    root = 1;
  }
  void addEdgeDirected(int u, int v, int w = 1, int id = 0) {
    adj[u].push_back(Edge(v, w, id));
  }
  void addEdgeUndirected(int u, int v, int w = 1) {
    adj[u].push_back(Edge(v, w));
    adj[v].push_back(Edge(u, w));
  }
  void getSubtreeNodesCount() {
    subtreeCount = vector<int>(n + 1, -1);
    for (int i = 1; i <= n; i++) {
      if (subtreeCount[i] == -1) {
        getSubtreeNodesCountRec(-1, i, subtreeCount);
      }
    }
  }
  long long getDiameter() { return getDiameterRec(-1, root).first; }
  void getParents() {
    parent = vector<int>(n + 1, -1);
    stack<int> st;
    st.push(root);
    while (!st.empty()) {
      int cur = st.top();
      st.pop();
      for (auto it : adj[cur]) {
        if (it.dest == parent[cur]) continue;
        parent[it.dest] = cur;
        st.push(it.dest);
      }
    }
  }
  void DFS() {
    int DFSTime = 0;
    startTime = vector<int>(n + 1, -1);
    finishTime = vector<int>(n + 1, -1);
    nodeStartingAt = vector<int>(n + 1, -1);
    getParents();
    DFSRec(root, DFSTime);
  }
  void getDistArray() {
    dist = vector<long long>(n + 1, INF);
    dist[root] = 0;
    queue<int> q;
    q.push(root);
    while (!q.empty()) {
      int cur = q.front();
      q.pop();
      for (auto it : adj[cur]) {
        if (it.dest == parent[cur]) continue;
        dist[it.dest] = dist[cur] + it.weight;
        q.push(it.dest);
      }
    }
  }
  void initLCA() {
    pos.resize(n + 1);
    anc.resize(17 + 1);
    for (auto& it : anc) it.resize(n + 1, 0);
    getParents();
    for (int i = (1); i <= (n); ++i) anc[0][i] = parent[i];
    for (int i = (1); i <= (n); ++i) pos[i] = -1;
    pos[root] = 0;
    anc[0][root] = root;
    for (int i = 1; i <= n; i++) {
      if (pos[i] == -1) getPos(i);
    }
    for (int i = 1; i <= 17; i++) {
      for (int j = 1; j <= n; j++) {
        anc[i][j] = anc[i - 1][anc[i - 1][j]];
      }
    }
  }
  int lca(int u, int v) {
    if (pos[u] < pos[v]) swap(u, v);
    int diff = pos[u] - pos[v];
    for (int k = (17); k >= (0); --k)
      if ((1 << k) <= diff) {
        diff -= 1 << k;
        u = anc[k][u];
      }
    if (u == v) return u;
    for (int k = (17); k >= (0); --k)
      if (anc[k][u] != anc[k][v]) {
        u = anc[k][u];
        v = anc[k][v];
      }
    return parent[u];
  }
  long long distBetween(int u, int v) {
    int lcaNode = lca(u, v);
    long long ans = dist[u] + dist[v] - 2 * dist[lcaNode];
    return ans;
  }
  int kthParent(int u, int k) {
    bitset<20> bitmask(k);
    int ans = u;
    for (int i = 0; i < 20; i++) {
      if (bitmask[i]) {
        ans = anc[i][ans];
      }
    }
    return ans;
  }

 private:
  vector<int> pos;
  vector<vector<int>> anc;
  int getPos(int u) {
    if (pos[u] == -1) pos[u] = getPos(parent[u]) + 1;
    return pos[u];
  }
  void DFSRec(int cur, int& DFSTime) {
    nodeStartingAt[DFSTime] = cur;
    startTime[cur] = DFSTime++;
    for (auto it : adj[cur]) {
      if (it.dest != parent[cur]) {
        DFSRec(it.dest, DFSTime);
      }
    }
    finishTime[cur] = DFSTime;
  }
  int getSubtreeNodesCountRec(int par, int cur,
                              vector<int>& subtreeNodesCount) {
    int mySize = 1;
    for (auto it : adj[cur]) {
      if (it.dest == par) continue;
      mySize += getSubtreeNodesCountRec(cur, it.dest, subtreeNodesCount);
    }
    return subtreeNodesCount[cur] = mySize;
  }
  pair<long long, long long> getDiameterRec(int par, int cur) {
    long long diam = 0;
    long long maxHeight[3] = {0, 0, 0};
    for (auto it : adj[cur]) {
      if (it.dest == par) continue;
      pair<long long, long long> subtreeDiam = getDiameterRec(cur, it.dest);
      diam = max(diam, subtreeDiam.first);
      maxHeight[0] = subtreeDiam.second + it.weight;
      sort(maxHeight, maxHeight + 3);
    }
    diam = max(diam, maxHeight[1] + maxHeight[2]);
    return {diam, maxHeight[2]};
  }
};
Tree tree;
vector<long long> ans;
void calc(int cur, int par) {
  ans[cur] = ans[par] + tree.n - 2LL * tree.subtreeCount[cur];
  for (auto it : tree.adj[cur]) {
    if (it.dest == par) continue;
    calc(it.dest, cur);
  }
}
int main() {
  std::ios::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.tie(0);
  int n;
  cin >> n;
  tree = Tree(n);
  ans = vector<long long>(n + 1);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    tree.addEdgeUndirected(u, v);
  }
  tree.getSubtreeNodesCount();
  ans[1] =
      accumulate(tree.subtreeCount.begin() + 1, tree.subtreeCount.end(), 0LL);
  for (auto it : tree.adj[1]) calc(it.dest, 1);
  cout << *max_element(ans.begin() + 1, ans.end()) << "\n";
}
