#include <bits/stdc++.h>
using namespace std;
int n, a[500050], rt, f[500050][20];
long long ans;
vector<int> adj[500050];
void dfs(int u) {
  long long curmin = 1LL << 60;
  for (register int i = 1; i < 20; ++i) f[u][i] = f[f[u][i - 1]][i - 1];
  for (register int i = 0; i < 20; ++i)
    curmin = min(curmin, 1ll * a[f[u][i]] * (i + 1));
  if (u != rt) ans += curmin + a[u];
  for (auto v : adj[u]) {
    if (v != f[u][0]) f[v][0] = u, dfs(v);
  }
}
int main() {
  int u, v;
  scanf("%d", &n);
  a[0] = 1e9 + 7;
  for (register int i = 1; i <= n; ++i)
    scanf("%d", &a[i]), a[i] < a[rt] ? rt = i : 0;
  for (register int i = 1; i < n; ++i)
    scanf("%d%d", &u, &v), adj[u].push_back(v), adj[v].push_back(u);
  f[rt][0] = rt, dfs(rt);
  cout << ans << endl;
  return 0;
}
