#include <bits/stdc++.h>
using namespace std;
const int maxn = 500050;
const long long inf = 1e18;
int a[maxn];
vector<int> G[maxn];
int f[maxn][20], root;
long long ans = 0;
void dfs(int x, int par) {
  f[x][0] = par;
  long long t = inf;
  if (par) t = a[x] + a[par];
  for (int i = 1; f[x][i - 1]; ++i) {
    f[x][i] = f[f[x][i - 1]][i - 1];
    if (f[x][i])
      t = min(t, (1ll + i) * a[f[x][i]] + a[x]);
    else
      t = min(t, (1ll + i) * a[root] + a[x]);
  }
  if (par) ans += t;
  for (auto &v : G[x]) {
    if (v != par) dfs(v, x);
  }
}
int main() {
  int n;
  scanf("%d", &n);
  root = 1;
  for (int i = 1; i <= n; ++i)
    scanf("%d", a + i), a[i] < a[root] ? root = i : 0;
  for (int i = 0; i < n - 1; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    G[x].push_back(y);
    G[y].push_back(x);
  }
  dfs(root, 0);
  cout << ans << endl;
  return 0;
}
