#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 5e5 + 5;
long long a[maxn];
int fa[maxn][20];
vector<int> e[maxn];
int n;
long long ans;
void dfs(int u, int pre) {
  fa[u][0] = pre;
  for (int i = 1; i <= 19; ++i) {
    fa[u][i] = fa[fa[u][i - 1]][i - 1];
  }
  long long res = INF;
  for (int i = 0; i <= 19; ++i) {
    res = min(res, (1ll + i) * a[fa[u][i]] + a[u]);
  }
  if (u != pre) ans += res;
  for (auto v : e[u]) {
    if (v == pre) continue;
    dfs(v, u);
  }
}
int main() {
  scanf("%d", &n);
  int rt = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", &a[i]);
    if (i == 1 || a[i] < a[rt]) rt = i;
  }
  for (int i = 1; i <= n - 1; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    e[u].push_back(v);
    e[v].push_back(u);
  }
  ans = 0;
  dfs(rt, rt);
  printf("%lld\n", ans);
  return 0;
}
