#include <bits/stdc++.h>
std::vector<int> node[524288];
int a[524288];
int w[524288];
long long int dust[524288];
int res[524288];
long long int base;
int tm[524288];
int par[524288];
int n, cnt;
void _dfs(int p, int u) {
  for (auto v : node[u])
    if (v != p) _dfs(u, v);
  tm[u] = cnt++;
  for (auto v : node[u])
    if (v != p) par[tm[v]] = tm[u];
}
void dfs() {
  for (int i = 0; i < n; ++i) dust[i] = w[i], res[i] = 0;
  for (int i = 0; i < n; ++i) {
    if (dust[i] >= base) ++res[i], dust[i] = 0;
    res[par[i]] += res[i], dust[par[i]] += std::max(0ll, dust[i]);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", a + i);
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d%d", &u, &v), --u, --v;
    node[u].push_back(v);
    node[v].push_back(u);
  }
  _dfs(0, 0), par[tm[0]] = n;
  for (int i = 0; i < n; ++i) w[tm[i]] = a[i];
  long long int ans = -((int)1e9 + 1);
  int k = 0;
  for (long long int i = 1ll << 50; i; i >>= 1)
    if (base = ans + i, dfs(), res[tm[0]]) ans += i, k = res[tm[0]];
  printf("%lld %d\n", ans * k, k);
  return 0;
}
