#include <iostream>
#include <vector>
#define ll long long
#define endl '\n'
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll n, kb, c1, c2;
    vector<ll>dp(n+1);
    cin>>n;
    dp[0]=0;
    for(int i=1; i<n+1; i++){
        cin>>kb; dp[i]=dp[i-1]+kb;
    }
    ll br1=0;
    bool ind2=false;
    for(int i=0; i<n-1; i++){
        cin>>c1>>c2;
        if(c1==1 || c2==1) br1++;
    }
    if(br1==n-1){
        if(dp[1]<=dp[n]-dp[1]){
            cout<<dp[1]<<endl;
            cout<<1<<endl;
            cout<<1<<endl;
            cout<<0<<endl;
        }
        else{
            cout<<dp[n]-dp[1]<<endl;
            cout<<n-1<<endl;
            for(int i=2; i<n+1; i++){
                cout<<i<<" ";
            }
            cout<<endl;
            cout<<0<<endl;
        }
    }
    
}