#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e6 + 10;
const long long inf = 1e18 + 2137;
long long c[MAXN];
long long dp[MAXN][2];
vector<long long> g[MAXN];
bool reach[MAXN][2];
bool ans[MAXN];
void dfs(long long u, long long p) {
  if (g[u].size() == 1 && u != 1) {
    dp[u][1] = c[u];
    return;
  }
  long long diff = -inf;
  for (auto v : g[u])
    if (v != p)
      dfs(v, u), dp[u][0] += dp[v][1], diff = max(diff, dp[v][1] - dp[v][0]);
  dp[u][1] = min(dp[u][0], dp[u][0] - diff + c[u]);
  dp[u][0] -= diff;
}
void solve(long long u, long long p) {
  if (g[u].size() == 1 && u != 1) {
    if (reach[u][1]) ans[u] = true;
    return;
  }
  long long diff = -inf, mins = 0, sum = 0;
  for (auto v : g[u])
    if (v != p) diff = max(diff, dp[v][1] - dp[v][0]), sum += dp[v][1];
  for (auto v : g[u])
    if (v != p && dp[v][1] - dp[v][0] == diff) mins++;
  if (reach[u][1]) {
    if (dp[u][1] == sum) {
      for (auto v : g[u])
        if (v != p) reach[v][1] = true;
    }
    if (dp[u][1] == sum - diff + c[u]) {
      ans[u] = true;
      for (auto v : g[u])
        if (v != p && dp[v][1] - dp[v][0] == diff)
          reach[v][0] = true;
        else
          reach[v][1] = true;
      if (mins > 1) {
        for (auto v : g[u])
          if (v != p && dp[v][1] - dp[v][0] == diff) reach[v][1] = true;
      }
    }
  }
  if (reach[u][0]) {
    for (auto v : g[u])
      if (v != p && dp[v][1] - dp[v][0] == diff)
        reach[v][0] = true;
      else
        reach[v][1] = true;
    if (mins > 1) {
      for (auto v : g[u])
        if (v != p && dp[v][1] - dp[v][0] == diff) reach[v][1] = true;
    }
  }
  for (auto v : g[u])
    if (v != p) solve(v, u);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, i, a, b, res = 0;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> c[i];
  for (i = 1; i < n; i++)
    cin >> a >> b, g[a].emplace_back(b), g[b].emplace_back(a);
  dfs(1, 0);
  reach[1][1] = true;
  solve(1, 0);
  for (i = 1; i <= n; i++)
    if (ans[i]) res++;
  cout << dp[1][1] << " " << res << "\n";
  for (i = 1; i <= n; i++)
    if (ans[i]) cout << i << " ";
}
