#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x7f7f7f7f;
const int N = 1e6 + 10;
int n, cnt, rt;
int a[N], w[N], head[N], fa[N][25], dep[N];
long long ans;
struct Edge {
  int to, next;
  Edge() {}
  Edge(int tt, int nn) { to = tt, next = nn; }
} e[N << 1];
void add(int u, int v) {
  e[++cnt] = Edge(v, head[u]);
  head[u] = cnt;
}
void dfs(int u, int pre) {
  fa[u][0] = pre;
  long long sum = inf;
  for (long long i = 1; i < 25; i++)
    sum = min(sum, i * a[fa[u][i - 1]]), fa[u][i] = fa[fa[u][i - 1]][i - 1];
  sum += a[u];
  if (u != pre) ans += sum;
  for (int k = head[u]; k != -1; k = e[k].next) {
    int v = e[k].to;
    if (v == pre) continue;
    dfs(v, u);
  }
}
int main() {
  scanf("%d", &n);
  a[rt] = inf;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[rt] > a[i]) rt = i;
  }
  memset(head, -1, sizeof(head));
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    add(u, v), add(v, u);
  }
  dfs(rt, rt);
  printf("%lld\n", ans);
  return 0;
}
