#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long long Mod = 1000000007LL, INF = 1e9, LINF = 1e18;
const long double Pi = 3.141592653589793116, EPS = 1e-9,
                  Gold = ((1 + sqrt(5)) / 2);
long long keymod[] = {1000000007LL, 1000000009LL, 1000000021LL, 1000000033LL};
long long keyCount = sizeof(keymod) / sizeof(long long);
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng64(chrono::steady_clock::now().time_since_epoch().count());
template <class T>
int getbit(T s, int i) {
  return (s >> i) & 1;
}
template <class T>
T onbit(T s, int i) {
  return s | (T(1) << i);
}
template <class T>
T offbit(T s, int i) {
  return s & (~(T(1) << i));
}
template <class T>
int cntbit(T s) {
  return __builtin_popcountll(s);
}
auto TimeStart = chrono::steady_clock::now();
auto TimeEnd = chrono::steady_clock::now();
void ControlIO(int argc, char* argv[]);
void TimerStart();
void TimerStop();
void Exit();
string cppstr_infile = "FILE.IN";
string cppstr_outfile = "FILE.OUT";
int n;
vector<int> c;
vector<long long> dp;
vector<vector<int>> adj;
vector<vector<int>> DependencyList;
set<int> FinalList;
void DFS_GetList(int z, int last, vector<int>& MaxLeaf, vector<int>& MaxID,
                 vector<int>& MaxCnt) {
  dp[z] = 0;
  bool isLeaf = true;
  for (auto t : adj[z]) {
    if (t == last) continue;
    isLeaf = false;
    DFS_GetList(t, z, MaxLeaf, MaxID, MaxCnt);
    dp[z] += dp[t];
    if (MaxLeaf[t] >= MaxLeaf[z]) MaxID[z] = MaxID[t];
    if (MaxLeaf[t] > MaxLeaf[z])
      MaxCnt[z] = MaxCnt[t];
    else if (MaxLeaf[t] == MaxLeaf[z])
      MaxCnt[z] += MaxCnt[t];
    MaxLeaf[z] = max(MaxLeaf[z], MaxLeaf[t]);
  }
  if (isLeaf) {
    MaxLeaf[z] = dp[z] = c[z];
    MaxID[z] = z;
    MaxCnt[z] = 1;
    DependencyList[z].push_back(z);
    return;
  }
  int MaxRemovable = -MaxLeaf[z];
  if (MaxRemovable + c[z] > 0) return;
  if (MaxRemovable + c[z] < 0 && MaxCnt[z] == 1) {
    DependencyList[MaxID[z]].clear();
  }
  if (MaxCnt[z] == 1)
    DependencyList[MaxID[z]].push_back(z);
  else {
    DependencyList[z].push_back(z);
    MaxID[z] = z;
  }
  dp[z] += (MaxRemovable + c[z]);
  MaxLeaf[z] = c[z];
  MaxCnt[z] = 1;
}
void Input() {
  cin >> n;
  c.resize(n);
  dp.resize(n);
  adj.resize(n);
  DependencyList.resize(n);
  for (auto& z : c) cin >> z;
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
}
void Solve() {
  vector<int> MaxLeaf(n, -1), MaxID(n, -1), MaxCnt(n, 0);
  DFS_GetList(0, -1, MaxLeaf, MaxID, MaxCnt);
  for (int id = 0; id < n; id++) {
    for (auto z : DependencyList[id]) FinalList.insert(z + 1);
  }
  cout << dp[0] << " " << FinalList.size() << '\n';
  for (auto it = FinalList.begin(); it != FinalList.end(); it++)
    cout << (*it) << " ";
  cout << '\n';
}
int main(int argc, char* argv[]) {
  ControlIO(argc, argv);
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  Input();
  TimerStart();
  Solve();
  TimerStop();
  return 0;
}
void ControlIO(int argc, char* argv[]) {
  char* infile = new char[cppstr_infile.size() + 1];
  char* outfile = new char[cppstr_outfile.size() + 1];
  strcpy(infile, cppstr_infile.c_str());
  strcpy(outfile, cppstr_outfile.c_str());
}
void TimerStart() {}
void TimerStop() {}
void Exit() {
  TimerStop();
  exit(0);
}
