#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long double eps = 1e-7;
const int inf = 1000000010;
const long long INF = 10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 500010, LOG = 20;
long long n, m, k, u, v, x, y, t, a, b, ans, root = 1;
int A[MAXN];
int par[MAXN][LOG];
int mn[MAXN][LOG];
vector<int> G[MAXN];
void dfs(int node, int p) {
  mn[node][0] = A[par[node][0] = p];
  for (int i = 1; i < LOG; i++) {
    par[node][i] = par[par[node][i - 1]][i - 1];
    mn[node][i] = min(mn[node][i], mn[par[node][i - 1]][i - 1]);
  }
  for (int i : G[node])
    if (i != p) dfs(i, node);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  memset(mn, 63, sizeof(mn));
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> A[i];
    if (A[i] < A[root]) root = i;
  }
  for (int i = 0; i < n - 1; i++) {
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs(root, root);
  for (int i = 1; i <= n; i++)
    if (i != root) {
      long long tmp = INF;
      for (long long lg = 0; lg < LOG; lg++)
        tmp = min(tmp, (lg + 1) * mn[i][lg] + A[i]);
      ans += tmp;
    }
  cout << ans << '\n';
  return 0;
}
