#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];
/**
dp[x][0] - Ja sam 1
dp[x][1] - Ja sam 0, moj parent je 1
dp[x][2] - Ja sam 0, moj parent je 0
*/

void calcdp(int gde,int pret,int d){
   for(int x:stablo[gde])
      if(x!=pret)
         calcdp(x,gde,d^1);
   dub[gde]=d;

   /// dp 0
   ll suma=0;
   for(int x:stablo[gde])
      if(x!=pret)
         suma+=min(dp[x][0],min(dp[x][1],dp[x][2]));
   dp[gde][0]=niz[gde]+suma;
   /// dp 1
   suma=0;
   for(int x:stablo[gde])
      if(x!=pret)
         suma+=min(dp[x][0],dp[x][2]);
   dp[gde][1]=suma;
   /// dp 2

   if(stablo[gde].size()==1 and pret!=gde){
      dp[gde][2]=1e18;
      return;
   }

   ll best,skor=1e18;
   for(int x:stablo[gde]){
      if(x==pret)
         continue;
      ll ts=dp[x][0]-dp[x][2];
      if(ts<skor){
         skor=ts;
         best=x;
      }
   }
   suma=0;
   for(int x:stablo[gde]){
      if(x==pret)
         continue;
      if(x==best)
         suma+=dp[x][0];
      else
         suma+=min(dp[x][2],dp[x][0]);
   }
   dp[gde][2]=suma;
   return;
}
void kon(int gde,int pret,bool sta,bool par){
   //cout<<gde<<" "<<pret<<" "<<sta<<endl;
   if(sta)
      V[dub[gde]].push_back(gde);
   if(sta==true){
      for(int x:stablo[gde])
         if(x!=pret)
            kon(x,gde,dp[x][0]<=dp[x][1],true);
      return;
   }
   if(par){
      for(int x:stablo[gde])
         if(x!=pret)
            kon(x,gde,dp[x][0]<=dp[x][2],false);
      return;
   }
   ll best,skor=1e18;
   for(int x:stablo[gde]){
      if(x==pret)
         continue;
      ll ts=dp[x][0]-dp[x][2];
      if(ts<skor){
         skor=ts;
         best=x;
      }
   }
   for(int x:stablo[gde]){
      if(x==pret)
         continue;
      if(x==best)
         kon(x,gde,true,false);
      else
         kon(x,gde,dp[x][0]<=dp[x][2],false);
   }
}
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]<<" "<<dp[i][2]<<endl;

   kon(1,1,(dp[1][0]<=dp[1][2]),false);

   cout<<min(dp[1][0],dp[1][2])<<"\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";
}
/*
4
1 100 100 1
1 2
2 3
3 4
*/
void reset(){}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int T=1;
    //cin>>T;
    while(T--){
        solve();
        reset();
    }
    return 0;
}