#include <bits/stdc++.h>
long long min(long long a, long long b) { return a < b ? a : b; }
int oo[1 + 500000 - 1], oj[1 + 500000 - 1];
int link(int o, int j) {
  static int _ = 1;
  oo[_] = o, oj[_] = j;
  return _++;
}
int aa[500000], ae[500000], stack[500000];
long long ans;
void dfs(int i, int d) {
  int o;
  stack[d] = i;
  if (d > 0) {
    long long w_;
    int h;
    w_ = 0x3f3f3f3f3f3f3f3fLL;
    for (h = 0; 1 << h <= d; h++)
      w_ = min(w_, (long long)aa[stack[d - (1 << h)]] * (h + 1) + aa[i]);
    w_ = min(w_, (long long)aa[stack[0]] * (h + 1) + aa[i]);
    ans += w_;
  }
  for (o = ae[i]; o; o = oo[o]) {
    int j = oj[o];
    dfs(j, d + 1);
  }
}
int main() {
  int n, h, i, i_, j;
  scanf("%d", &n);
  i_ = -1;
  for (i = 0; i < n; i++) {
    scanf("%d", &aa[i]);
    if (i_ == -1 || aa[i_] > aa[i]) i_ = i;
  }
  for (h = 0; h < n - 1; h++) {
    int tmp;
    scanf("%d%d", &i, &j), i--, j--;
    if (aa[i] > aa[j]) tmp = i, i = j, j = tmp;
    ae[i] = link(ae[i], j);
  }
  dfs(i_, 0);
  printf("%lld\n", ans);
  return 0;
}
