#include <bits/stdc++.h>
using namespace std;
vector<int> G[300005];
long long score[300005], ar[300005], mx, ans;
void solve(int u, int par, int f) {
  score[u] = ar[u];
  for (auto v : G[u]) {
    if (v == par) continue;
    solve(v, u, f);
    score[u] = max(score[u], score[u] + score[v]);
  }
  if (f && score[u] == mx) ans++, score[u] = 0;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &ar[i]);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  solve(1, 0, 0);
  mx = score[1];
  for (int i = 1; i <= n; i++) mx = max(mx, score[i]);
  solve(1, 0, 1);
  printf("%lld %lld\n", ans * mx, ans);
  return 0;
}
