#include <bits/stdc++.h>
using namespace std;
const int mn = 5e5 + 5;
int n;
int a[mn];
vector<int> g[mn];
long long ans;
int mini, choose;
int parent[mn][21];
long long dp[mn][21];
vector<int> v;
void dfs(int x, int fa) {
  v.push_back(x);
  for (auto &i : g[x]) {
    if (i != fa) {
      dfs(i, x);
    }
  }
  if (x != choose) {
    int now = (int)v.size() - 1;
    long long u = 1e18;
    int c = -1, del = 1;
    while (1) {
      if (c == -1)
        del = 1;
      else
        del = (1 << c);
      now -= del;
      c++;
      if (now <= 0) {
        now = 0;
        u = min(u, 1ll * a[v[now]] * (c + 1));
        break;
      }
      u = min(u, 1ll * a[v[now]] * (c + 1));
    }
    ans += u + a[x];
  }
  v.pop_back();
}
int main() {
  scanf("%d", &n);
  mini = 1e9, choose = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (mini > a[i]) {
      mini = a[i];
      choose = i;
    }
  }
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  memset(parent, -1, sizeof parent);
  dfs(choose, 0);
  printf("%lld\n", ans);
  return 0;
}
