#include <bits/stdc++.h>
using namespace std;
int n;
int a[500010];
const int M = 20;
int f[500010][M];
int g[500010][M];
struct Edge {
  int v, nxt;
} e[1000010];
int tot;
int first[500010];
void build(int u, int v) {
  e[++tot] = (Edge){v, first[u]};
  first[u] = tot;
  return;
}
long long ans = 0;
void dfs(int u, int lst) {
  f[u][0] = lst;
  if (lst)
    g[u][0] = a[lst];
  else
    g[u][0] = 1e9 + 7;
  for (int i = 1; i < M; i++) {
    f[u][i] = f[f[u][i - 1]][i - 1];
    g[u][i] = g[u][i - 1];
    if (f[u][i - 1]) g[u][i] = min(g[u][i], g[f[u][i - 1]][i - 1]);
  }
  if (lst) {
    ans += a[u];
    long long mn = 1e15;
    for (int i = 0; i < M; i++) mn = min(mn, 1ll * g[u][i] * (i + 1));
    ans += mn;
  }
  for (int i = first[u]; i; i = e[i].nxt)
    if (e[i].v != lst) dfs(e[i].v, u);
  return;
}
int main() {
  scanf("%d", &n);
  int s = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] < a[s]) s = i;
  }
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    build(u, v);
    build(v, u);
  }
  dfs(s, 0);
  printf("%lld\n", ans);
  return 0;
}
