#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 5;
vector<int> adj[maxn];
int N, a[maxn];
int par[maxn][20], depth[maxn];
int mn = -1;
long long res;
void dfs(int u, int p = -1) {
  par[u][0] = p;
  for (int i = 1; i < 20; ++i) {
    if (par[u][i - 1] != -1) {
      par[u][i] = par[par[u][i - 1]][i - 1];
    } else {
      par[u][i] = -1;
    }
  }
  long long cost = 1e18;
  int i;
  for (i = 0; i < 20 && par[u][i] != -1; ++i) {
    cost = min(cost, (long long)(i + 1) * a[par[u][i]] + a[u]);
  }
  cost = min(cost, (long long)(i + 1) * a[mn] + a[u]);
  if (p != -1) res += cost;
  for (int v : adj[u]) {
    if (v != p) {
      dfs(v, u);
    }
  }
}
signed main(void) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> N;
  for (int i = 1; i <= N; ++i) {
    cin >> a[i];
    if (mn == -1 || a[mn] > a[i]) {
      mn = i;
    }
  }
  for (int i = 1; i < N; ++i) {
    int u, v;
    cin >> u >> v;
    adj[u].emplace_back(v);
    adj[v].emplace_back(u);
  }
  dfs(mn);
  cout << res;
}
