#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10, M = 6e5 + 10;
long long dp[N], a[N], n, ans, cnt;
long long head[N], Next[M], ver[M], tot;
void add(int x, int y) {
  ver[++tot] = y;
  Next[tot] = head[x];
  head[x] = tot;
}
void dfs1(int x, int fa) {
  dp[x] = a[x];
  for (int i = head[x]; i; i = Next[i]) {
    int y = ver[i];
    if (y == fa) continue;
    dfs1(y, x);
    dp[x] += max(dp[y], 0LL);
  }
  ans = max(ans, dp[x]);
}
void dfs2(int x, int fa) {
  dp[x] = a[x];
  for (int i = head[x]; i; i = Next[i]) {
    int y = ver[i];
    if (y == fa) continue;
    dfs2(y, x);
    dp[x] += max(dp[y], 0LL);
  }
  if (dp[x] == ans) {
    dp[x] = 0;
    ++cnt;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  memset(head, 0, sizeof(head));
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  ans = a[1];
  cnt = 0;
  for (int i = 1; i <= n - 1; i++) {
    int x, y;
    cin >> x >> y;
    add(x, y), add(y, x);
  }
  dfs1(1, -1);
  dfs2(1, -1);
  cout << ans * cnt << " " << cnt << endl;
  return 0;
}
