#include <bits/stdc++.h>
using namespace std;
long long a[500005], sol;
vector<int> ms[500005];
int par[25][500005], n;
const long long inf = 1e15;
void dfs(int x, int p) {
  for (int i = 1; i <= 20; ++i) {
    par[i][x] = par[i - 1][par[i - 1][x]];
  }
  for (vector<int>::iterator i = ms[x].begin(); i != ms[x].end(); ++i) {
    int o = *i;
    if (o == p) continue;
    par[0][o] = x;
    dfs(o, x);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  long long mini = inf;
  int koji = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    if (a[i] < mini) {
      mini = a[i];
      koji = i;
    }
  }
  for (int i = 0; i < n - 1; ++i) {
    int x, y;
    cin >> x >> y;
    ms[x].push_back(y);
    ms[y].push_back(x);
  }
  par[0][koji] = koji;
  dfs(koji, -1);
  for (int i = 1; i <= n; ++i) {
    if (i == koji) continue;
    sol += a[i];
    mini = inf;
    for (int j = 0; j <= 20; ++j) {
      mini = min(mini, (j + 1) * a[par[j][i]]);
    }
    sol += mini;
  }
  cout << sol << endl;
  return 0;
}
