#include <bits/stdc++.h>
using namespace std;
int a[400005];
vector<int> v[400005];
long long dp[400005];
long long ans, num = 0;
void dfs(int x, int fa) {
  dp[x] = a[x];
  for (int i = 0; i < v[x].size(); i++) {
    int node = v[x][i];
    if (node == fa) continue;
    dfs(node, x);
    dp[x] += max(0LL, dp[node]);
  }
  ans = max(dp[x], ans);
}
void dfs2(int x, int fa) {
  dp[x] = a[x];
  for (int i = 0; i < v[x].size(); i++) {
    int node = v[x][i];
    if (node == fa) continue;
    dfs2(node, x);
    dp[x] += max(0LL, dp[node]);
  }
  if (dp[x] == ans) {
    num++;
    dp[x] = -0x3f3f3f3f;
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n - 1; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  ans = -0x3f3f3f3f;
  dfs(1, 0);
  memset(dp, 0, sizeof dp);
  dfs2(1, 0);
  printf("%lld %lld\n", ans * num, num);
  return 0;
}
