#include <bits/stdc++.h>
using namespace std;
const int N = 5e5;
const int logn = 20;
vector<int> v[N + 1];
long long ar[N + 1];
int dplca[logn][N], par[N], level[N];
int n;
void dfs0(int i) {
  for (int j = 0; j < v[i].size(); ++j)
    if (v[i][j] != dplca[0][i]) {
      level[v[i][j]] = level[i] + 1;
      par[v[i][j]] = i;
      dplca[0][v[i][j]] = i;
      dfs0(v[i][j]);
    }
}
void preprocess(int x) {
  memset(dplca, -1, sizeof(dplca));
  level[x] = 1;
  dplca[0][x] = -1;
  par[x] = -1;
  dfs0(x);
  for (int i = 1; i < logn; ++i)
    for (int j = 1; j <= n; ++j) {
      if (dplca[i - 1][j] != -1) dplca[i][j] = dplca[i - 1][dplca[i - 1][j]];
    }
}
long long ans = 0;
long long X;
void dfs(int i, int p) {
  if (p != -1) {
    long long x = 1e15;
    long long j;
    for (j = 0; j < logn; ++j) {
      if (dplca[j][i] == -1) break;
      x = min(x, j * ar[dplca[j][i]] + ar[dplca[j][i]] + ar[i]);
    }
    x = min(x, j * X + X + ar[i]);
    ans = ans + x;
  }
  for (int j = 0; j < v[i].size(); ++j)
    if (v[i][j] != p) dfs(v[i][j], i);
}
int main() {
  std::ios::sync_with_stdio(false);
  int T;
  T = 1;
  while (T--) {
    int i, j, a, b;
    cin >> n;
    int pos = 1;
    for (i = 1; i <= n; ++i) {
      cin >> ar[i];
      if (ar[i] < ar[pos]) pos = i;
    }
    for (i = 1; i <= n - 1; ++i) {
      cin >> a >> b;
      v[a].push_back(b);
      v[b].push_back(a);
    }
    preprocess(pos);
    X = ar[pos];
    dfs(pos, -1);
    cout << ans << endl;
  }
  return 0;
}
