#include <bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;

int N, K, A[100500], u, v;
vector<int> VG[100500];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> A[i];
    for(int i = 1; i < N; i++)
    {
        cin >> u >> v;
        VG[u].pb(v);
        VG[v].pb(u);
    }
    cout << A[1] << "\n";
    cout << 1 << "\n";
    cout << 1 << "\n";
    cout << 0 << "\n";
    return 0;
}