#include <bits/stdc++.h>
using namespace std;
const int N = 500005;
int n, a[N], rt = 1, dp[N][20];
long long ans;
vector<int> e[N];
void dfs(int pos, int fa) {
  dp[pos][0] = fa;
  long long mn = a[fa];
  int i;
  for (i = 1; i < 20; i++) {
    dp[pos][i] = dp[dp[pos][i - 1]][i - 1];
    if (!dp[pos][i]) break;
    mn = min(mn, (i + 1) * 1ll * a[dp[pos][i]]);
  }
  mn = min(mn, (i + 1) * 1ll * a[rt]);
  if (pos != rt) ans += mn + a[pos];
  for (auto &i : e[pos])
    if (i != fa) dfs(i, pos);
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  int t1, t2;
  for (int i = 1; i < n; i++) {
    cin >> t1 >> t2;
    e[t1].push_back(t2);
    e[t2].push_back(t1);
  }
  for (int i = 2; i <= n; i++)
    if (a[i] < a[rt]) rt = i;
  dfs(rt, 0);
  cout << ans << endl;
  return 0;
}
