#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int w = 1, s = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    s = s * 10 + ch - '0';
    ch = getchar();
  }
  return w * s;
}
struct node {
  int to, next;
} e[1000010];
int h[1000010], tot, n, A[1000010], fa[500010][20], rt;
long long ans = 0;
inline void add(int from, int to) {
  e[++tot].next = h[from];
  h[from] = tot;
  e[tot].to = to;
}
inline void DFS(int now, int ffa) {
  for (register int i = 1; i <= 19; ++i) fa[now][i] = fa[fa[now][i - 1]][i - 1];
  if (now != rt) {
    long long Mn = 1e18;
    for (register int i = 0; i <= 19; ++i) {
      if (!fa[now][i]) fa[now][i] = rt;
      Mn = min(Mn, (1ll + i) * A[fa[now][i]] + A[now]);
    }
    ans += Mn;
  }
  for (register int i = h[now]; i; i = e[i].next) {
    int to = e[i].to;
    if (to == ffa) continue;
    fa[to][0] = now;
    DFS(to, now);
  }
}
int main() {
  n = read();
  int Min = 1e9, pos = 1;
  for (register int i = 1; i <= n; ++i) {
    A[i] = read();
    if (A[i] < Min) pos = i, Min = A[i];
  }
  rt = pos;
  for (register int i = 1, u, v; i < n; ++i)
    u = read(), v = read(), add(u, v), add(v, u);
  DFS(rt, 0);
  cout << ans;
  return 0;
}
