//Dedicated to my love, ivaziva
#include "bits/stdc++.h"
#define dbg(x) cerr << #x << ": " << x << endl;
#define ll long long
#define pb push_back
#define all(a) a.begin(),a.end()
#define si(s) (ll)(s.size())
using namespace std;
#define maxn 200005


int n;
int a[maxn];

signed main(){
	ios_base::sync_with_stdio(false);
	cout.tie(0); cin.tie(0); cerr.tie(0);

    cin >> n;
    int x = (int)(1e9 + 1), idx = 0;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        if(a[i] < x) {
            x = a[i];
            idx = i;
        }
    }
    int u, v;
    bool drugi_tc = true;
    for(int i = 1; i <= n - 1; i++) {
        cin >> u >> v;
        drugi_tc &= (u == 1 || v == 1);
    }
    if(drugi_tc) {
        cout << x << '\n';
        cout << 1 << '\n';
        cout << idx << '\n';
        cout << 0 << '\n';
        return 0;
    }
    cout << "racku\n";
	return 0;
}