#include <bits/stdc++.h>
using i64 = long long;
std::vector<i64> a;
std::vector<std::deque<int>> g;
i64 cnt = 0;
i64 maxsum = std::numeric_limits<i64>::min();
i64 dfs(int v, int p) {
  i64 ret = a[v];
  for (auto c : g[v]) {
    if (c == p) continue;
    ret += dfs(c, v);
  }
  maxsum = std::max(maxsum, ret);
  return std::max(ret, 0ll);
}
i64 count(int v, int p) {
  i64 sum = a[v];
  for (auto c : g[v]) {
    if (c == p) continue;
    sum += count(c, v);
  }
  if (sum == maxsum) {
    cnt++;
    return 0;
  } else {
    return std::max(sum, 0ll);
  }
}
int main() {
  int n;
  scanf("%d", &n);
  g.resize(n);
  a.resize(n);
  for (auto &el : a) scanf("%lld", &el);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(0, -1);
  count(0, -1);
  printf("%lld %lld\n", maxsum * cnt, cnt);
  return 0;
}
