#include <bits/stdc++.h>
using namespace std;
const long long N = 5e5 + 20, inf = 1e18, LG = 25;
long long par[N][LG], a[N], mn, mni, w;
vector<int> gr[N];
void dfs(int v) {
  for (int i = 1; i < LG; i++) {
    par[v][i] = par[par[v][i - 1]][i - 1];
  }
  long long tmp = inf;
  if (v != mni) {
    int i = 0;
    while (par[v][i] != 0 && i < LG) {
      tmp = min(tmp, ((i + 1) * a[par[v][i]] + a[v]));
      i++;
    }
    tmp = min(tmp, ((i + 1) * mn + a[v]));
    w += tmp;
  }
  for (auto u : gr[v])
    if (u != par[v][0]) par[u][0] = v, dfs(u);
}
int main() {
  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  int n;
  cin >> n;
  mn = inf, mni = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (mn > a[i]) mni = i;
    mn = min(mn, a[i]);
  }
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    gr[u].push_back(v);
    gr[v].push_back(u);
  }
  par[mni][0] = 0;
  dfs(mni);
  cout << w;
}
