#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10, lg = 20;
int n, minvert = 1;
int w[N], par[lg][N];
long long ans;
vector<int> adj[N];
void DFS(int u, int pr) {
  par[0][u] = pr;
  for (int i = 1; i < lg; i++) par[i][u] = par[i - 1][par[i - 1][u]];
  long long tmp = w[pr] + w[u];
  for (int t = 1; t < lg; t++)
    tmp = min(tmp, (long long)(t + 1) * w[par[t][u]] + w[u]);
  if (pr != u) ans += tmp;
  for (auto v : adj[u]) {
    if (v == pr) continue;
    DFS(v, u);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> w[i];
    if (w[i] < w[minvert]) minvert = i;
  }
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  DFS(minvert, minvert);
  cout << ans << "\n";
}
