#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1000000007;
const long long int INF = 2000000000;
const long long BIG = 1446803456761533460LL;
const long long int maxn = 500010;
const long long int maxnlg = 20;
long long int n, A[maxn], pars[maxnlg][maxn], ans = 0;
vector<long long int> g[maxn];
void dfs(long long int x, long long int par = -1) {
  for (auto y : g[x])
    if (y != par) {
      long long int w = A[x];
      pars[0][y] = x;
      for (long long int i = 0; i < maxnlg - 1; ++i) {
        pars[i + 1][y] = pars[i][pars[i][y]];
        w = min(w, (A[pars[i + 1][y]] * (i + 2)));
      }
      ans += A[y] + w;
      dfs(y, x);
    }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  long long int mni = 0;
  for (long long int i = 0; i < n; ++i) {
    cin >> A[i];
    if (A[mni] > A[i]) mni = i;
  }
  for (long long int i = 0; i < n - 1; ++i) {
    long long int a, b;
    cin >> a >> b;
    --a, --b;
    g[a].emplace_back(b), g[b].emplace_back(a);
  }
  for (long long int i = 0; i < maxnlg; ++i) pars[i][mni] = mni;
  dfs(mni);
  cout << ans << '\n';
}
