#include <bits/stdc++.h>
using namespace std;
const long long M = 5e5 + 133, INF = 1e18 + 10, ML = 25;
long long a[M], dp[ML][M], ans = 0;
vector<int> adj[M];
void dfs(int v, int p) {
  dp[0][v] = p;
  long long x = a[p];
  for (int i = 1; i <= 19; i++) {
    dp[i][v] = dp[i - 1][dp[i - 1][v]];
    x = min(x, a[dp[i][v]] * (1 + i));
  }
  if (v != p) ans += a[v] + x;
  for (int u : adj[v]) {
    if (u != p) dfs(u, v);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  long long mi = INF, r = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] < mi) mi = a[i], r = i;
  }
  for (int i = 1; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  dfs(r, r);
  cout << ans;
}
