func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 5e5 + 8;   int a[N], fa[N][20];   vector<int> E[N];   long long res;   void dfs(int x, int f) {     fa[x][0] = f;     long long temp = a[f];     for (int i = 1; i < 20; i++) {       fa[x][i] = fa[fa[x][i - 1]][i - 1];       temp = min(temp, (i + 1ll) * a[fa[x][i]]);     }     if (f != x) res += temp + a[x];     for (int &e : E[x])       if (e != f) dfs(e, x);   }   int main() {     ios::sync_with_stdio(false);     int n, rt = 0;     a[0] = INT_MAX;     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i], rt = a[rt] < a[i] ? rt : i;     for (int i = 1, u, v; i < n; i++)       cin >> u >> v, E[u].push_back(v), E[v].push_back(u);     dfs(rt, rt);     cout << res <<   n ;     return 0;   }   