#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
const int maxn = 5e5 + 10;
const int maxm = 1e5 + 10;
long long a[maxn];
vector<int> vec[maxn];
int par[22][maxn];
void dfs(int u, int fa) {
  for (int i = 0; i + 1 <= 20; i++) par[i + 1][u] = par[i][par[i][u]];
  for (int i = 0; i < vec[u].size(); i++) {
    int v = vec[u][i];
    if (v == fa) continue;
    par[0][v] = u;
    dfs(v, u);
  }
}
int main() {
  int n;
  scanf("%d", &n);
  int root = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    if (a[i] < a[root]) root = i;
  }
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    vec[u].push_back(v);
    vec[v].push_back(u);
  }
  par[0][root] = root;
  dfs(root, 0);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (i == root) continue;
    ans += a[i];
    long long mn = a[par[0][i]];
    for (int j = 0; j <= 20; j++) mn = min(mn, 1ll * (j + 1) * a[par[j][i]]);
    ans += mn;
  }
  printf("%lld\n", ans);
  return 0;
}
