#include <bits/stdc++.h>
#define ios ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl '\n'
#define pb push_back
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int maxN = 1e5 + 5;
int main(){
    ios;
    int n;
    cin>>n;
    vector<ll> a(n+1);
    for(int i = 1;i<=n;i++)cin>>a[i];
    vector<vector<int>> g(n + 1);
    bool podzadatak1 = true;
    for(int i = 0;i < n - 1;i++){
        int u, v;
        cin>>u>>v;
        g[u].pb(v);
        g[v].pb(u);
        if(u!=1&&v!=1)podzadatak1 = false;
    }
    ll mn = LLONG_MAX;
    int idx = 0;
    for(int i = 1;i<=n;i++){
        if(a[i]<=mn){
            mn = a[i];
            idx = i;
        }
    }
    cout<<0<<endl;
    cout<<0<<endl;
    cout<<0<<endl;



}