#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
vector<int> G[maxn], ans;
vector<pair<int, int> > P[maxn][2];
long long a[maxn], dp[maxn][2];
int vis[maxn][2];
int n;
void dfs(int u, int f) {
  const static long long oo = 1ll << 60;
  int flg = 1;
  long long mx = -oo, cnt = 1;
  for (auto &v : G[u]) {
    if (v == f) continue;
    flg = 0;
    dfs(v, u);
    long long tmp = dp[v][0] - dp[v][1];
    if (tmp > mx)
      mx = tmp, cnt = 1;
    else if (tmp == mx)
      ++cnt;
    dp[u][0] += dp[v][0];
  }
  if (flg)
    dp[u][0] = a[u];
  else {
    dp[u][1] = dp[u][0] - mx;
    for (auto &v : G[u]) {
      if (v == f) continue;
      if (dp[v][0] - dp[v][1] == mx) {
        P[u][1].push_back({v, 1});
        if (cnt >= 2) P[u][1].push_back({v, 0});
      } else
        P[u][1].push_back({v, 0});
    }
    long long tmp1 = dp[u][0];
    long long tmp2 = dp[u][0] + a[u] - mx;
    dp[u][0] = min(tmp1, tmp2);
    if (dp[u][0] == tmp1) {
      for (auto &v : G[u]) {
        if (v == f) continue;
        P[u][0].push_back({v, 0});
      }
    }
    if (dp[u][0] == tmp2) {
      for (auto &v : G[u]) {
        if (v == f) continue;
        if (dp[v][0] - dp[v][1] == mx) {
          P[u][0].push_back({v, 1});
          if (cnt >= 2) P[u][0].push_back({v, 0});
        } else
          P[u][0].push_back({v, 0});
      }
    }
  }
}
void print(int u, int f) {
  vis[u][f] = 1;
  int cnt = 0, flg = 1;
  for (auto &e : P[u][f]) {
    int v = e.first, p = e.second;
    flg = 0;
    cnt += p;
    if (vis[v][p]) continue;
    print(v, p);
  }
  if (flg && !f) ans.push_back(u);
  if (!flg && !f && cnt) ans.push_back(u);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i < n; ++i) {
    int u, v;
    cin >> u >> v;
    G[u].push_back(v), G[v].push_back(u);
  }
  dfs(1, 0);
  print(1, 0);
  sort(ans.begin(), ans.end());
  ans.erase(unique(ans.begin(), ans.end()), ans.end());
  cout << dp[1][0] << " " << ((int)ans.size()) << endl;
  for (auto &v : ans) cout << v << " ";
  cout << endl;
  return 0;
}
