#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 100;
long long a[maxn];
long long ans;
long long minn;
vector<int> v[maxn], q;
long long n;
void dfs(long long i, long long j) {
  if (i != minn) {
    long long d = 1LL * 1e18;
    for (long long y = 0; y <= 20; y++) {
      if ((1 << y) <= q.size()) {
        d = min(d, (y + 1) * q[q.size() - ((1 << y))]);
      } else {
        d = min(d, (y + 1) * q[0]);
        break;
      }
    }
    ans += d + a[i];
  }
  q.push_back(a[i]);
  for (long long y = 0; y < v[i].size(); y++) {
    long long x = v[i][y];
    if (x != j) dfs(x, i);
  }
  q.pop_back();
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  a[0] = 1LL * 1e10;
  cin >> n;
  for (long long y = 1; y <= n; y++) {
    cin >> a[y];
    if (a[minn] > a[y]) minn = y;
  }
  for (long long y = 0; y < n - 1; y++) {
    long long i, j;
    cin >> i >> j;
    v[i].push_back(j);
    v[j].push_back(i);
  }
  dfs(minn, 0);
  cout << ans;
}
