#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
inline long long read() {
  char c = getchar();
  long long x = 0;
  bool f = 0;
  for (; !isdigit(c); c = getchar()) f ^= !(c ^ 45);
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  if (f) x = -x;
  return x;
}
long long n, res, rt;
struct edge {
  long long to, nxt;
} e[500005 << 1];
long long tot, head[500005];
inline void adde(long long u, long long v) {
  e[++tot] = (edge){v, head[u]};
  head[u] = tot;
}
long long a[500005], fa[500005][21];
void dfs(long long u, long long pa) {
  fa[u][0] = pa;
  long long minn = a[pa];
  for (register long long i = (1); i <= (20); ++i) {
    fa[u][i] = fa[fa[u][i - 1]][i - 1];
    if (!fa[u][i]) {
      minn = min(minn, a[rt] * (i + 1));
      break;
    }
    minn = min(minn, a[fa[u][i]] * (i + 1));
  }
  if (pa) res += a[u] + minn;
  for (long long i = head[u]; i; i = e[i].nxt) {
    long long v = e[i].to;
    if (v == pa) continue;
    dfs(v, u);
  }
}
signed main() {
  n = read();
  for (register long long i = (1); i <= (n); ++i) a[i] = read();
  for (register long long i = (2); i <= (n); ++i) {
    long long u = read(), v = read();
    adde(u, v);
    adde(v, u);
  }
  rt = 1;
  for (register long long i = (1); i <= (n); ++i)
    if (a[i] < a[rt]) rt = i;
  dfs(rt, 0);
  cout << res;
  return 0;
}
