#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = (int)1e9 + 7;
const int N = (int)3e5 + 7;
int n;
long long a[N], mx, cnt;
vector<int> e[N];
long long dfs(int u, int f, bool flag) {
  long long res = a[u];
  for (auto v : e[u])
    if (v != f) {
      res += max(0ll, dfs(v, u, flag));
    }
  if (!flag)
    mx = max(mx, res);
  else {
    if (res == mx) {
      cnt++;
      res = -LINF;
    }
  }
  return res;
}
void Init() {
  mx = -LINF;
  cnt = 0;
  for (int i = (0); i < (n + 1); ++i) e[i].clear();
  for (int i = (1); i < (n + 1); ++i) scanf("%lld", a + i);
  for (int i = (1); i < (n); ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    e[u].push_back(v);
    e[v].push_back(u);
  }
}
int Solve() {
  dfs(1, 1, 0);
  dfs(1, 1, 1);
  return printf("%lld %lld\n", cnt * mx, cnt);
}
int main() {
  while (~scanf("%d", &n)) {
    Init();
    Solve();
  }
  return 0;
}
