#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 10;
long long a[N], ans, r = 1;
vector<int> adj[N], vec;
void DFS(int v, int p = 0) {
  long long mn = 2000000001, h = vec.size(), lg = 0;
  for (; (1 << lg) < h; lg++)
    mn = min(mn, a[vec[h - (1 << lg)]] * (lg + 1) + a[v]);
  mn = min(mn, (h ? a[vec[0]] * (lg + 1) + a[v] : 0));
  ans += mn;
  vec.push_back(v);
  for (int u : adj[v])
    if (u != p) DFS(u, v);
  vec.pop_back();
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    r = (a[i] < a[r] ? i : r);
  }
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  DFS(r);
  cout << ans;
  return 0;
}
