#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int N = 3e5 + 5;
vector<int> v[N];
long long dp[N];
long long ans = -INF;
int a[N];
int k = 0;
void dfs(int node, int anc = -1) {
  for (int to : v[node]) {
    if (to != anc) {
      dfs(to, node);
      if (dp[to] > 0) dp[node] += dp[to];
    }
  }
  dp[node] += a[node];
}
void walk(int node, int anc = -1) {
  for (int to : v[node]) {
    if (to != anc) {
      walk(to, node);
      if (dp[to] != ans && dp[to] > 0) dp[node] += dp[to];
    }
  }
  dp[node] += a[node];
  if (dp[node] == ans) k++;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--, y--;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs(0);
  for (int i = 0; i < n; i++) {
    ans = max(ans, dp[i]);
  }
  fill(dp, dp + n, 0);
  walk(0);
  printf("%lld %d", ans * k, k);
  return 0;
}
