#include <bits/stdc++.h>
using namespace std;
int a[300005], n, k;
long long dp[300005], ans = -1e9;
vector<int> v[300005];
void dfs(int nod, int p, bool f) {
  dp[nod] = a[nod];
  for (int u : v[nod]) {
    if (u != p) {
      dfs(u, nod, f);
      dp[nod] += max(dp[u], 0LL);
    }
  }
  if (f)
    ans = max(ans, dp[nod]);
  else if (dp[nod] == ans) {
    dp[nod] = 0;
    k++;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  dfs(1, 0, 1);
  dfs(1, 0, 0);
  cout << ans * k << " " << k;
  return 0;
}
