#include <bits/stdc++.h>
using namespace std;
long long dp[300005], a[300005];
long long A = -2E18;
int n, cnt, f;
vector<int> G[300005];
void dfs(int u, int p) {
  dp[u] = a[u];
  for (auto v : G[u]) {
    if (v != p) {
      dfs(v, u);
      dp[u] += max(0LL, dp[v]);
    }
  }
  A = max(A, dp[u]);
  if (f == 1 && dp[u] == A) {
    dp[u] = 0;
    cnt++;
  }
}
int main() {
  f = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs(1, 0);
  f = 1;
  dfs(1, 0);
  printf("%lld %d\n", A * cnt, cnt);
  return 0;
}
