#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
vector<int> g[N];
long long ans = 0;
int p[N][20];
int a[N];
int Root = 1;
void dfs(int u, int P) {
  for (int i = 0; i < 18; ++i) p[u][i + 1] = p[p[u][i]][i];
  int Log;
  long long res = 1e18;
  for (Log = 0; Log < 20 && p[u][Log]; ++Log)
    res = min(res, 1ll * (Log + 1) * a[p[u][Log]] + a[u]);
  res = min(res, 1ll * (Log + 1) * a[Root] + a[u]);
  if (P) ans += res;
  for (int v : g[u])
    if (v != P) p[v][0] = u, dfs(v, u);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    if (a[Root] > a[i]) Root = i;
  }
  for (int i = 2; i <= n; ++i) {
    int x;
    cin >> x;
    int y;
    cin >> y;
    g[x].emplace_back(y);
    g[y].emplace_back(x);
  }
  dfs(Root, 0);
  cout << ans << endl;
}
