#include<bits/stdc++.h> using namespace std; int n,a[1000005]; int res = 0; int lc[1000005],rc[1000005],siz[1000005]; int dfs(int root) { siz[root]=1; if(lc[root] != -1) siz[root]+=dfs(lc[root]); if(rc[root] != -1) siz[root]+=dfs(rc[root]); return siz[root]; } b...