#include <bits/stdc++.h>
using namespace std;
long long n;
long long a[300005];
vector<vector<long long> > g;
long long dp[300005];
long long findBest(long long cur, long long par) {
  long long ans = a[cur];
  for (auto child : g[cur]) {
    if (child == par) continue;
    long long v = findBest(child, cur);
    if (v > 0) ans += v;
  }
  dp[cur] = ans;
  return ans;
}
long long cnt = 0;
long long best;
long long dp2[300005];
long long rec(long long cur, long long par) {
  long long ans = a[cur];
  for (auto child : g[cur]) {
    if (child == par) continue;
    long long v = rec(child, cur);
    if (v > 0) ans += v;
  }
  assert(ans <= best);
  if (ans == best) {
    cnt++;
    return 0;
  } else {
    return ans;
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> a[i];
  g.resize(n);
  for (long long i = 0; i < n - 1; i++) {
    long long u, v;
    cin >> u >> v;
    u--, v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  findBest(0, -1);
  best = LONG_LONG_MIN;
  for (long long i = 0; i < n; i++) best = max(best, dp[i]);
  rec(0, -1);
  assert(cnt > 0);
  cout << (best * cnt) << " " << cnt << endl;
}
