#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int p = 0, w = 1;
  char c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') w = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') p = p * 10 + c - '0', c = getchar();
  return p * w;
}
const int sid = 5e5 + 5;
const int cid = 1e6 + 5;
long long ans;
int up[sid][21];
int n, rt, cnp, minp = 1e9;
int a[sid], cap[sid], nxt[cid], node[cid];
inline void addedge(int u, int v) {
  nxt[++cnp] = cap[u];
  cap[u] = cnp;
  node[cnp] = v;
}
void dfs(int o, int fa) {
  long long tmp = 1e18;
  for (register int i = 1; i <= 19; i++) up[o][i] = up[up[o][i - 1]][i - 1];
  for (register int i = 0; i <= 19; i++)
    tmp = min(tmp, a[o] + 1ll * (i + 1) * a[up[o][i]]);
  if (o != rt) ans += tmp;
  for (int i = cap[o]; i; i = nxt[i])
    if (node[i] != fa) up[node[i]][0] = o, dfs(node[i], o);
}
int main() {
  n = read();
  for (register int i = 1; i <= n; i++) {
    a[i] = read();
    if (a[i] < minp) minp = a[i], rt = i;
  }
  for (register int i = 2; i <= n; i++) {
    int u = read(), v = read();
    addedge(u, v);
    addedge(v, u);
  }
  up[rt][0] = rt;
  dfs(rt, 0);
  printf("%lld\n", ans);
  return 0;
}
