#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
struct Edge {
  int v;
  int next;
} edge[maxn * 2];
int head[maxn];
int tol;
void addEdge(int u, int v) {
  edge[tol].v = v;
  edge[tol].next = head[u];
  head[u] = tol++;
}
long long a[maxn];
long long ans;
int ans1[maxn];
int in;
int flag[maxn];
int id[maxn];
int res[maxn];
vector<int> vec[maxn];
const int N = 2e5 + 5;
int n, fa[N], nxt[N];
bool pass_on[N], vis[N];
vector<int> e[N], Ans;
pair<int, int> dfs3(int p) {
  pair<int, int> ret = pair<int, int>(a[p], p), mx;
  vector<pair<int, int> > tmp;
  for (register int i = 0, v; i < e[p].size(); ++i)
    if ((v = e[p][i]) ^ fa[p]) fa[v] = p, tmp.push_back(dfs3(v));
  if (!tmp.size()) return ret;
  sort(tmp.begin(), tmp.end(), greater<pair<int, int> >());
  mx = tmp[0];
  int cnt = 0;
  for (register int i = 0; i < tmp.size(); ++i)
    if (tmp[i].first ^ mx.first)
      break;
    else
      ++cnt;
  for (register int i = 1; i < tmp.size(); ++i)
    pass_on[tmp[i].second] = 1, ans += tmp[i].first;
  if (cnt > 1) pass_on[mx.second] = 1;
  if (ret.first ^ mx.first) return min(ret, mx);
  return nxt[ret.second] = mx.second, ret;
}
int dfs(int s, int pre) {
  int cnt = 0;
  int mx = -1;
  int mxid = -1;
  id[s] = s;
  for (int i = head[s]; i != 0; i = edge[i].next) {
    int v = edge[i].v;
    if (v == pre) continue;
    int ele = dfs(v, s);
    if (mx < ele) {
      mx = ele;
      mxid = id[v];
    }
    cnt++;
  }
  for (int i = head[s]; i != 0; i = edge[i].next) {
    int v = edge[i].v;
    if (id[v] == mxid || v == pre) continue;
    int ele = res[v];
    if (mx == ele) {
      vec[id[v]].push_back(mxid);
      for (int j = 0; j < vec[mxid].size(); j++) {
        vec[id[v]].push_back(vec[mxid][j]);
      }
      vec[mxid].clear();
      break;
    }
  }
  if (cnt == 0) {
    flag[s] = 1;
    res[s] = a[s];
  } else {
    if (a[s] > mx) {
      id[s] = mxid;
      res[s] = mx;
    } else if (a[s] == mx) {
      vec[mxid].push_back(s);
      res[s] = mx;
      id[s] = mxid;
    } else {
      flag[s] = 1;
      flag[mxid] = 0;
      res[s] = a[s];
    }
  }
  return res[s];
}
void dfs2(int s, int pre) {
  if (flag[s]) {
    ans += a[s];
    ans1[++in] = s;
    for (int i = 0; i < vec[s].size(); i++) {
    }
  }
  for (int i = head[s]; i != 0; i = edge[i].next) {
    int v = edge[i].v;
    if (v == pre) continue;
    dfs2(v, s);
  }
}
int main() {
  int len1;
  scanf("%d", &len1);
  n = len1;
  for (int i = 1; i <= len1; i++) {
    scanf("%lld", &a[i]);
  }
  tol = 1;
  for (int i = 1; i < len1; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    e[u].push_back(v), e[v].push_back(u);
    addEdge(u, v);
    addEdge(v, u);
  }
  dfs(1, 0);
  dfs2(1, 0);
  long long sss = 858847430511901ll;
  if (0) {
    sort(ans1 + 1, ans1 + in + 1);
    int len = in;
    in = 0;
    for (int i = 1; i <= len; i++) {
      if (ans1[i - 1] != ans1[i]) ans1[++in] = ans1[i];
    }
    printf("%lld %d\n", ans, in);
    for (int i = 1; i < in; i++) {
      printf("%d ", ans1[i]);
    }
    printf("%d\n", ans1[in]);
  } else {
    ans = 0;
    pair<int, int> tmp = dfs3(1);
    ans += tmp.first, pass_on[tmp.second] = 1;
    for (register int i = 1; i <= n; ++i) {
      if (vis[i]) continue;
      bool f = 0;
      for (register int j = i; j; j = nxt[j]) {
        vis[j] = 1;
        pass_on[j] = (f |= pass_on[j]);
      }
    }
    for (register int i = 1; i <= n; ++i)
      if (pass_on[i]) Ans.push_back(i);
    cout << ans << ' ' << Ans.size() << '\n';
    for (register int i = 0; i < Ans.size(); ++i) cout << Ans[i] << ' ';
  }
}
