#include <bits/stdc++.h>
using namespace std;
const int N = 500010;
const int inf = 0x3f3f3f3f;
int tot, rt, a[N], dp[N][20], f[N][20];
int to[N << 1], nxt[N << 1], head[N];
long long res;
void addEdge(int u, int v) { to[++tot] = v, nxt[tot] = head[u], head[u] = tot; }
inline void dfs(int u) {
  for (int i = 1; i < 20; ++i) f[u][i] = f[f[u][i - 1]][i - 1];
  long long mn = inf;
  for (int i = 0; i < 20; ++i) {
    if (!f[u][i]) {
      mn = min(mn, 1ll * a[rt] * (i + 1));
      break;
    }
    mn = min(mn, 1ll * a[f[u][i]] * (i + 1));
  }
  if (u != rt) res += mn + a[u];
  for (int i = head[u]; i; i = nxt[i]) {
    int v = to[i];
    if (v == f[u][0]) continue;
    f[v][0] = u;
    dfs(v);
  }
}
int main() {
  int n;
  scanf("%d", &n);
  int mn = inf;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] < mn) mn = a[i], rt = i;
  }
  for (int i = 1, u, v; i < n; i++) {
    scanf("%d%d", &u, &v);
    addEdge(u, v);
    addEdge(v, u);
  }
  dfs(rt);
  printf("%lld\n", res);
}
