| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1191620 | SmuggingSpun | Sjekira (COCI20_sjekira) | C11 | 0 ms | 0 KiB | 
#include<bits/stdc++.h>
#define taskname "D"
using namespace std;
typedef long long ll;
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	if(fopen(taskname".inp", "r")){
		freopen(taskname".inp", "r", stdin);
	}
	int n;
	cin >> n;
	vector<int>a(n);
	ll ans = 0;
	for(int& x : a){
		cin >> x;
		ans += x;
	}
	for(int _ = 1; _ < n; _++){
		int u, v;
		cin >> u >> v;
		ans += max(a[u - 1], a[v - 1]);
	}
	cout << ans - *max_element(a.begin(), a.end());
}
