#include <bits/stdc++.h>
using namespace std;
const int N = 500005;
int n, p, a[N], q[N], lg[N];
vector<int> e[N];
long long ans;
void dfs(int x, int fa) {
  q[++*q] = x;
  if ((*q) != 1) {
    long long res = 1ll * a[q[1]] * lg[(*q) - 1] + a[x] + a[q[1]];
    for (int j = (int)(0); j <= (int)(18); j++)
      if ((*q) > (1 << j))
        res = min(res, 1ll * (j + 1) * a[q[(*q) - (1 << j)]] + a[x]);
    ans += res;
  }
  for (auto i : e[x])
    if (i != fa) dfs(i, x);
  --*q;
}
int main() {
  scanf("%d", &n);
  p = 1;
  for (int i = (int)(1); i <= (int)(n); i++) scanf("%d", &a[i]);
  for (int i = (int)(1); i <= (int)(n); i++)
    if (a[i] < a[p]) p = i;
  for (int i = (int)(2); i <= (int)(n); i++) lg[i] = lg[(i + 1) / 2] + 1;
  for (int i = (int)(1); i <= (int)(n - 1); i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    e[x].push_back(y);
    e[y].push_back(x);
  }
  dfs(p, 0);
  printf("%lld\n", ans);
}
