#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=2e5+5;
ll N,dp[maxn][5],niz[maxn],dub[maxn];
vector<int> stablo[maxn],V[5];
void calcdp(int gde,int pret,int d){
   for(int x:stablo[gde])
      if(x!=pret)
         calcdp(x,gde,d^1);
   dub[gde]=d;
   ll s0=niz[gde],s1=0;
   for(int x:stablo[gde]){
      s0+=min(dp[x][0],dp[x][1]);
      s1+=dp[x][1];
   }
   dp[gde][0]=s1;
   dp[gde][1]=s0;
   return;
}
void kon(int gde,int pret,bool sta){
   //cout<<gde<<" "<<pret<<" "<<sta<<endl;
   if(sta)
      V[dub[gde]].push_back(gde);
   if(sta==false){
      for(int x:stablo[gde])
         if(x!=pret)
            kon(x,gde,1);
      return;
   }
   for(int x:stablo[gde])
      if(x!=pret){
         if(dp[x][1]<dp[x][0])
            kon(x,gde,1);
         else
            kon(x,gde,0);
      }
}
void solve(){
   cin>>N;
   for(int i=1;i<=N;i++)
      cin>>niz[i];
   int a,b;
   for(int i=1;i<N;i++){
      cin>>a>>b;
      stablo[a].push_back(b);
      stablo[b].push_back(a);
   }
   calcdp(1,1,0);
//   for(int i=1;i<=N;i++)
 //     cout<<i<<" "<<dp[i][0]<<" "<<dp[i][1]<<endl;

   kon(1,1,(dp[1][1]<=dp[1][0]));
   cout<<min(dp[1][0],dp[1][1])<<"\n";
   cout<<V[0].size()<<"\n";
   for(int x:V[0])
      cout<<x<<" ";
   cout<<"\n";
   cout<<V[1].size()<<"\n";
   for(int x:V[1])
      cout<<x<<" ";
   cout<<"\n";
}
void reset(){}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int T=1;
    //cin>>T;
    while(T--){
        solve();
        reset();
    }
    return 0;
}