#include <bits/stdc++.h>
using namespace std;
long long a[400000];
long long dp[400000];
long long ans = -1e17;
int k;
vector<int> to[400000];
void dfs1(int x, int f) {
  dp[x] = a[x];
  for (int v : to[x]) {
    if (v != f) {
      dfs1(v, x);
      if (dp[v] > 0) dp[x] += dp[v];
    }
  }
  ans = max(ans, dp[x]);
}
void dfs2(int x, int f) {
  dp[x] = a[x];
  for (int v : to[x]) {
    if (v != f) {
      dfs2(v, x);
      if (dp[v] > 0) dp[x] += dp[v];
    }
  }
  if (dp[x] == ans) {
    dp[x] = 0;
    k++;
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    to[u].push_back(v);
    to[v].push_back(u);
  }
  dfs1(1, 0);
  dfs2(1, 0);
  cout << ans * k << " " << k << endl;
}
