#include <bits/stdc++.h>
using namespace std;
int cmin(long long &a, long long b) { return a > b ? a = b, 1 : 0; }
char IO;
template <class T = int>
T rd() {
  T s = 0;
  int f = 0;
  while (!isdigit(IO = getchar())) f |= IO == '-';
  do s = (s << 1) + (s << 3) + (IO ^ '0');
  while (isdigit(IO = getchar()));
  return f ? -s : s;
}
const int N = 2e5 + 10, INF = 1e9 + 10;
int n, a[N];
vector<int> G[N];
long long dp[N][2];
int son[N], mk[N];
void dfs(int u, int f) {
  long long mi = 1e18;
  for (int v : G[u])
    if (v != f) {
      dfs(v, u);
      dp[u][0] += dp[v][1];
      if (cmin(mi, dp[v][0] - dp[v][1])) son[u] = v;
      dp[u][1] += dp[v][1];
    }
  if (mi == 1e18) {
    dp[u][0] = 0, dp[u][1] = a[u];
  } else {
    dp[u][0] += mi, mk[u] = cmin(dp[u][1], dp[u][0] + a[u]);
  }
}
vector<int> ans;
void dfs(int u, int f, int k) {
  if (f && G[u].size() == 1) {
    if (k & 2) ans.push_back(u);
    return;
  }
  if (k & 2) {
    if (dp[u][1] == dp[u][0] + a[u]) ans.push_back(u);
    if (mk[u]) k ^= 2, k |= 1;
  }
  int c = 0;
  for (int v : G[u])
    if (v != f && dp[v][0] - dp[v][1] == dp[son[u]][0] - dp[son[u]][1]) c++;
  for (int v : G[u])
    if (v != f) {
      int s = 0;
      if (k & 1) {
        if (c == 1) {
          if (v != son[u])
            s |= 2;
          else
            s |= 1;
        } else {
          if (dp[v][0] - dp[v][1] == dp[son[u]][0] - dp[son[u]][1]) s |= 1;
          s |= 2;
        }
      }
      if (k & 2) s |= 2;
      dfs(v, u, s);
    }
}
int main() {
  for (int i = 1, iend = n = rd(); i <= iend; ++i) a[i] = rd();
  for (int i = 2, iend = n; i <= iend; ++i) {
    int u = rd(), v = rd();
    G[u].push_back(v), G[v].push_back(u);
  }
  dfs(1, 0), dfs(1, 0, 2);
  cout << dp[1][1] << ' ' << ans.size() << endl;
  sort(ans.begin(), ans.end());
  for (int i : ans) printf("%d ", i);
}
