#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000 * 1000 * 1000;
const long long LINF = INF * (long long)INF;
const int MAX = 200005;
int n;
int a[300005];
int visited[300005];
vector<vector<int> > g(300005);
long long dp[300005];
int mx = -INF;
map<long long, int> m;
long long sum = 0;
long long maxScore = 0;
void dfs(int u, int p = -1) {
  dp[u] = a[u];
  for (auto v : g[u]) {
    if (v != p) {
      dfs(v, u);
      dp[u] += dp[v];
    }
  }
  dp[u] = max(dp[u], 0LL);
  maxScore = max(maxScore, dp[u]);
}
int cnt = 0;
void dfs1(int u, int p = -1) {
  dp[u] = a[u];
  for (auto v : g[u]) {
    if (v != p) {
      dfs1(v, u);
      dp[u] += dp[v];
    }
  }
  if (dp[u] == maxScore) {
    dp[u] = 0;
    cnt++;
  }
  dp[u] = max(dp[u], 0LL);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mx = max(mx, a[i]);
  }
  if (mx <= 0) {
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      cnt += a[i] == mx;
    }
    cout << mx * (long long)cnt << " " << cnt << endl;
    return 0;
  }
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  int root = 0;
  for (int i = 0; i < n; i++)
    if (g[i].size() != 1) root = i;
  dfs(root);
  dfs1(root, -1);
  cout << maxScore * (long long)cnt << " " << cnt << endl;
  return 0;
}
