#include <bits/stdc++.h>
using namespace std;
int n, A[500005], x, y, cur, dep[500005];
long long int ans;
vector<int> v[500005];
void dfs(int node) {
  dep[cur] = node;
  long long int add = 1000000000000000000;
  for (int i = 0; i < 20; i++) {
    if (cur < (1 << i)) {
      add = min(add, 1ll * A[dep[0]] * (i + 1));
      break;
    }
    add = min(add, 1ll * A[dep[cur - (1 << i)]] * (i + 1));
  }
  if (cur) ans += (long long int)A[node] + add;
  for (int i = 0; i < (int)v[node].size(); i++) {
    int go = v[node][i];
    cur++;
    dfs(go);
    cur--;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &A[i]);
  }
  for (int i = 1; i < n; i++) {
    scanf("%d %d", &x, &y);
    if (A[x] > A[y]) swap(x, y);
    v[x].push_back(y);
  }
  int root = min_element(A + 1, A + n + 1) - A;
  dfs(root);
  printf("%lld\n", ans);
  return 0;
}
