#include <bits/stdc++.h>
using namespace std;
const int maxN = 5e5 + 5;
const int LOG = 20;
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
int a[maxN], par[LOG][maxN];
vector<int> G[maxN];
long long res = 0;
void LEVI(int v, int p) {
  par[0][v] = p;
  long long mn = a[p];
  for (int i = 1; i < LOG; i++) {
    par[i][v] = par[i - 1][par[i - 1][v]];
    mn = min(mn, 1ll * (i + 1) * a[par[i][v]]);
  }
  if (p != v) res += mn + a[v];
  for (int u : G[v])
    if (u != p) LEVI(u, v);
  return;
}
int main() {
  time_t START = clock();
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  int rt = min_element(a + 1, a + n + 1) - a;
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  LEVI(rt, rt);
  printf("%lld\n", res);
  time_t FINISH = clock();
  cerr << "Execution time: "
       << (long double)(FINISH - START) / CLOCKS_PER_SEC * 1000.0
       << " milliseconds.\n";
  return 0;
}
