#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math")
const long long maxn = 5e5 + 10, maxm = 2e3 + 10, lg = 19, mod = 1e9 + 7,
                inf = 1e18;
long long n, a[maxn], rt = 1, ans;
vector<long long> g[maxn];
long long par[maxn][lg + 1];
void dfs(long long v = rt, long long p = rt) {
  par[v][0] = p;
  for (int i = 1; i <= lg; i++) par[v][i] = par[par[v][i - 1]][i - 1];
  for (auto u : g[v])
    if (u != p) dfs(u, v);
  if (v != rt) {
    long long nans = inf;
    for (int i = 0; i <= lg; i++)
      nans = min(nans, (i + 1) * a[par[v][i]] + a[v]);
    ans += nans;
  }
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] < a[rt]) rt = i;
  }
  for (int i = 1; i < n; i++) {
    long long v, u;
    cin >> v >> u;
    g[v].push_back(u), g[u].push_back(v);
  }
  dfs();
  cout << ans;
  return 0;
}
