#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 10, mod = 1e9 + 7;
vector<long long> ve[N];
long long a[N];
pair<multiset<pair<long long, long long> >,
     multiset<pair<long long, long long> > >
    S[N];
set<long long> se[N];
void U(long long u, long long v) {
  if (S[u].first.size() + S[u].second.size() <
      S[v].first.size() + S[v].second.size())
    swap(S[u], S[v]);
  S[u].first.insert(S[v].first.begin(), S[v].first.end());
  S[v].first.clear();
  S[u].second.insert(S[v].second.begin(), S[v].second.end());
  S[v].second.clear();
}
long long ans = 0;
void dfs(long long u, long long f) {
  for (long long v : ve[u]) {
    if (v == f) continue;
    dfs(v, u);
    U(u, v);
  }
  if (S[u].first.size() == 0)
    S[u].first.insert({a[u], u});
  else {
    auto p = S[u].first.end();
    p--;
    pair<long long, long long> t = *p;
    if (a[u] <= t.first) {
      if (S[u].first.size() > 1) {
        p--;
        if ((*p).first != t.first) {
          S[u].first.erase(++p);
          if (a[u] == t.first) {
            if (se[u].size() < se[t.second].size()) swap(se[u], se[t.second]);
            se[u].insert(t.second);
            se[u].insert(se[t.second].begin(), se[t.second].end());
            se[t.second].clear();
          }
        } else
          ans -= t.first;
      } else {
        S[u].first.erase(p);
        if (a[u] == t.first) {
          if (se[u].size() < se[t.second].size()) swap(se[u], se[t.second]);
          se[u].insert(t.second);
          se[u].insert(se[t.second].begin(), se[t.second].end());
          se[t.second].clear();
        }
      }
      S[u].second.insert(S[u].first.begin(), S[u].first.end());
      S[u].first.clear();
      S[u].first.insert({a[u], u});
    }
  }
}
int main() {
  long long n;
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (long long i = 1, a, b; i < n; i++) {
    scanf("%lld %lld", &a, &b);
    ve[a].push_back(b);
    ve[b].push_back(a);
  }
  dfs(1, -1);
  set<long long> v;
  for (auto i : S[1].first) {
    ans += i.first;
    v.insert(i.second);
    for (long long j : se[i.second]) v.insert(j);
  }
  for (auto i : S[1].second) {
    ans += i.first;
    v.insert(i.second);
    for (long long j : se[i.second]) v.insert(j);
  }
  printf("%lld %d\n", ans, v.size());
  for (long long i : v) {
    printf("%lld ", i);
  }
}
