#include <bits/stdc++.h>
using namespace std;
int n, mini, valmini = 1e9 + 5;
vector<int> v[500005];
long long a[500005], val, dp[500005][20], rez;
void dfs(int nod, int tata) {
  if (tata != 0) {
    dp[nod][0] = tata;
    int i;
    for (i = 1; i <= 20; i++)
      if (dp[nod][i - 1] != -1) dp[nod][i] = dp[dp[nod][i - 1]][i - 1];
    val = 1e18;
    for (i = 0; (i <= 20) && (dp[nod][i] > -1); i++)
      val = min(val, a[nod] + (i + 1) * a[dp[nod][i]]);
    val = min(val, a[nod] + (i + 1) * a[mini]);
    rez += val;
  }
  for (auto it = v[nod].begin(); it != v[nod].end(); ++it)
    if (*it != tata) dfs(*it, nod);
}
int main() {
  int i, j, x, y;
  std::ios::sync_with_stdio(false);
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    if (valmini > a[i]) {
      valmini = a[i];
      mini = i;
    }
  }
  for (i = 1; i < n; i++) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  for (i = 0; i <= 20; i++)
    for (j = 1; j <= n; j++) dp[j][i] = -1;
  dfs(mini, 0);
  cout << rez;
  return 0;
}
