#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10;
const int64_t INF = 1e18 + 10;
const int MOD = 1e9 + 7;
const double EPS = 1e-14;
const int64_t logmax = 25;
int64_t a[N], deep[N];
vector<int64_t> tree[N];
int64_t jump[logmax][N];
struct edge {
  int64_t w;
  int64_t u, v;
  edge(int64_t nw, int64_t nu, int64_t nv) {
    w = nw;
    u = nu;
    v = nv;
  }
};
bool operator<(edge a, edge b) { return (a.w > b.w); }
void dfs(int64_t cur, int64_t prev) {
  deep[cur] = deep[prev] + 1;
  jump[0][cur] = prev;
  for (int64_t log = 1; log < logmax; log++) {
    jump[log][cur] = jump[log - 1][jump[log - 1][cur]];
  }
  for (auto u : tree[cur]) {
    if (u == prev) continue;
    dfs(u, cur);
  }
}
int64_t kruscal(int64_t root) {
  priority_queue<edge> q;
  int64_t arr = 0;
  q.push({0, root, root});
  while (!q.empty()) {
    auto e = q.top();
    q.pop();
    arr += e.w;
    for (auto u : tree[e.u]) {
      if (a[u] < a[e.u]) continue;
      int64_t now = e.u;
      int64_t best = INF;
      for (int64_t d = 0; d < logmax; d++) {
        int64_t ancestor = jump[d][u];
        if (a[u] + a[ancestor] * (d + 1) < best) {
          best = a[u] + a[ancestor] * (d + 1);
          now = ancestor;
        }
      }
      q.push({best, u, now});
    }
  }
  return arr;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int64_t n;
  cin >> n;
  for (int64_t i = 1; i <= n; i++) cin >> a[i];
  for (int64_t i = 1; i < n; i++) {
    int64_t u, v;
    cin >> u >> v;
    tree[u].push_back(v);
    tree[v].push_back(u);
  }
  int64_t root = -1;
  for (int64_t i = 1; i <= n; i++) {
    if (root == -1 || a[root] > a[i]) root = i;
  }
  dfs(root, root);
  cout << kruscal(root);
}
