#include <bits/stdc++.h>
using namespace std;
long long n;
std::vector<long long> adj[300006];
std::vector<long long> w(300006);
long long dp[300006];
long long vis[300006];
std::vector<long long> ans;
long long sum = -1000000007, cc = 0;
void dfs1(long long node) {
  vis[node] = 1;
  dp[node] = w[node];
  for (auto i : adj[node]) {
    if (!vis[i]) {
      dfs1(i);
      if (dp[i] >= 0) dp[node] += dp[i];
    }
  }
  sum = max(sum, dp[node]);
}
void dfs2(long long node) {
  vis[node] = 1;
  dp[node] = w[node];
  for (auto i : adj[node]) {
    if (!vis[i]) {
      dfs2(i);
      if (dp[i] >= 0) dp[node] += dp[i];
    }
  }
  if (dp[node] == sum) {
    cc++;
    dp[node] = 0;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  long long cnt = 0, s = 0;
  long long mx1 = -1000000007;
  long long cnt1 = 0;
  for (long long int i = 1; i < n + 1; i++) {
    cin >> w[i];
    mx1 = max(mx1, w[i]);
    if (w[i] >= 0) cnt++;
    s += w[i];
  }
  for (long long int i = 0; i < n - 1; i++) {
    long long x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  memset(dp, -1000000007, sizeof(dp));
  long long mx = -1000000007;
  dfs1(1);
  memset(dp, -1000000007, sizeof(dp));
  memset(vis, 0, sizeof(vis));
  dfs2(1);
  cout << sum * cc << " " << cc;
}
