#include <bits/stdc++.h>
using namespace std;
int stramos[21][500001];
vector<int> graph[500001];
long long costs[500001];
void buildStramos(int n) {
  for (int i = 1; i <= 20; ++i) {
    for (int j = 1; j <= n; ++j) {
      stramos[i][j] = stramos[i - 1][stramos[i - 1][j]];
    }
  }
}
void dfs(int node, int father) {
  stramos[0][node] = father;
  for (auto x : graph[node]) {
    if (x == father) continue;
    dfs(x, node);
  }
}
long long getAnswer(int root, int n) {
  long long total = 0;
  for (int i = 1; i <= n; ++i) {
    if (i == root) continue;
    int logarithm = 0;
    int power = 1;
    long long minimCurrent = (1LL << 59);
    while (power <= n) {
      int ancestor = stramos[logarithm][i];
      minimCurrent = min(minimCurrent, costs[ancestor] * (logarithm + 1));
      power <<= 1;
      logarithm += 1;
    }
    int ancestor = stramos[logarithm][i];
    minimCurrent = min(minimCurrent, costs[ancestor] * (logarithm + 1));
    total += minimCurrent + costs[i];
  }
  return total;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, best = 1;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> costs[i];
    if (costs[best] > costs[i]) best = i;
  }
  for (int i = 1; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    graph[x].push_back(y);
    graph[y].push_back(x);
  }
  dfs(best, best);
  buildStramos(n);
  cout << getAnswer(best, n);
  return 0;
}
