#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int n;
vector<int> adj[maxn];
long long cost[maxn], dp[maxn][2];
void dfs(int v, int p) {
  if ((int)adj[v].size() - (p != 0) == 0) {
    dp[v][0] = cost[v];
    dp[v][1] = 0;
    return;
  }
  long long zersum = 0;
  for (int to : adj[v])
    if (to != p) {
      dfs(to, v);
      zersum += dp[to][0];
    }
  dp[v][0] = zersum;
  dp[v][1] = 1e18;
  for (int to : adj[v])
    if (to != p) {
      dp[v][0] = min(dp[v][0], zersum + cost[v] - dp[to][0] + dp[to][1]);
      dp[v][1] = min(dp[v][1], zersum - dp[to][0] + dp[to][1]);
    }
}
set<int> ans;
void dfs2(int v, int p, int st) {
  if ((int)adj[v].size() - (p != 0) == 0) {
    if (st == 0) ans.insert(v);
    return;
  }
  long long zersum = 0;
  for (int to : adj[v])
    if (to != p) zersum += dp[to][0];
  int u = -1;
  for (int to : adj[v])
    if (to != p) {
      if (st == 0) {
        if (dp[v][0] == zersum + cost[v] - dp[to][0] + dp[to][1]) {
          ans.insert(v);
          if (u == -1)
            u = to;
          else
            u = 0;
        }
      } else {
        if (dp[v][1] == zersum - dp[to][0] + dp[to][1]) {
          if (u == -1)
            u = to;
          else
            u = 0;
        }
      }
    }
  if (st == 0 && zersum == dp[v][0]) u = 0;
  for (int to : adj[v])
    if (to != p) {
      if (u == to)
        dfs2(to, v, 1);
      else
        dfs2(to, v, 0);
    }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> cost[i];
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  dfs(1, 0);
  cout << dp[1][0] << " ";
  dfs2(1, 0, 0);
  cout << (int)ans.size() << "\n";
  for (int v : ans) cout << v << " ";
  cout << "\n";
  return 0;
}
