#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = (int)1e9 + 7;
const int N = (int)2e5 + 7;
int _, w[N], l[N], r[N], pa[N];
vector<int> e[N], p;
vector<pair<pair<int, int>, pair<int, int> > > v;
void dfs(int u, int f) {
  l[u] = _;
  if ((int)(e[u]).size() == 1 && u != 1) ++_;
  for (int v : e[u]) {
    if (v != f) dfs(v, u);
  }
  r[u] = _;
}
int Find(int x) { return pa[x] = pa[x] == x ? x : Find(pa[x]); }
int main() {
  int n;
  scanf("%d", &n);
  for (int i = (1); i < (n + 1); ++i) scanf("%d", &w[i]);
  for (int i = (1); i < (n); ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    e[u].push_back(v);
    e[v].push_back(u);
  }
  dfs(1, -1);
  for (int i = (1); i < (n + 1); ++i) {
    v.push_back(make_pair(make_pair(w[i], i), make_pair(l[i], r[i])));
  }
  for (int i = (0); i < (n); ++i) pa[i] = i;
  sort((v).begin(), (v).end());
  long long ans = 0;
  for (int i = 0, j; i < n; i = j) {
    for (j = i; j < n && v[j].first.first == v[i].first.first; j++)
      ;
    for (int k = (i); k < (j); ++k) {
      int x = Find(v[k].second.first), y = Find(v[k].second.second);
      if (x != y) {
        p.push_back(v[k].first.second);
      }
    }
    for (int k = (i); k < (j); ++k) {
      int x = Find(v[k].second.first), y = Find(v[k].second.second);
      if (x != y) {
        pa[x] = y;
        ans += v[i].first.first;
      }
    }
  }
  printf("%lld %d\n", ans, (int)(p).size());
  sort((p).begin(), (p).end());
  for (int i = (0); i < ((int)(p).size()); ++i) {
    printf("%d ", p[i]);
  }
  printf("\n");
  return 0;
}
