#include <bits/stdc++.h>
using namespace std;
const int MX = 500005;
int n, u, v, lvl[MX], p[MX][20], l[MX], root = 1;
vector<int> adj[MX];
long long a[MX], res = 0;
void pre(int u, int w) {
  for (int v : adj[u])
    if (v != w) {
      lvl[v] = lvl[u] + 1;
      p[v][0] = u;
      pre(v, u);
    }
}
void dfs(int u, int w) {
  long long mn = 1e18;
  for (int i = 0; i < 20; i++) mn = min(mn, (i + 1) * a[p[u][i]] + a[u]);
  res += mn;
  for (int v : adj[u])
    if (v != w) dfs(v, u);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i + 1];
    if (a[i + 1] < a[root]) root = i + 1;
  }
  for (int i = 0; i < n - 1; i++) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  p[root][0] = root;
  pre(root, root);
  for (int j = 1; j < 20; j++)
    for (int i = 1; i <= n; i++) p[i][j] = p[p[i][j - 1]][j - 1];
  for (int v : adj[root]) dfs(v, root);
  cout << res << '\n';
  return 0;
}
