#include <bits/stdc++.h>
using namespace std;
vector<int> vc[400000];
long long dp[400000];
int ara[400000];
long long gt, hor;
void dp_func(int v, int par, int bol) {
  dp[v] = ara[v];
  for (int i = 0; i < vc[v].size(); i++) {
    int w = vc[v][i];
    if (w == par) continue;
    dp_func(w, v, bol);
    if (dp[w] < 0) continue;
    dp[v] += dp[w];
  }
  if (bol == 1)
    gt = max(gt, dp[v]);
  else if (bol == 0 && dp[v] == gt) {
    dp[v] = 0;
    hor++;
  }
}
int main() {
  int i, j, k, l, m, n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> ara[i];
  for (int i = 0; i < n - 1; i++) {
    scanf("%d%d", &l, &k);
    vc[l].push_back(k);
    vc[k].push_back(l);
  }
  gt = -(1LL << 55);
  dp_func(1, -1, 1);
  dp_func(1, -1, 0);
  printf("%lld %lld\n", gt * hor, hor);
}
