#include <bits/stdc++.h>
using namespace std;
long long int v[300001], sol[300001], S;
int cnt = 0, marked[300001], dp[300001][2];
vector<int> g[300001];
long long int dfs(int node, int p) {
  sol[node] = v[node];
  long long int res = sol[node];
  for (auto it : g[node])
    if (it != p) {
      res = max(res, dfs(it, node));
      if (sol[it] > 0) sol[node] += sol[it];
    }
  res = max(res, sol[node]);
  return res;
}
void getcnt(int node, int p) {
  for (auto it : g[node])
    if (it != p) {
      getcnt(it, node);
      if (sol[it] > 0 && marked[it]) marked[node] = 1;
    }
  if (!marked[node] && sol[node] == S) {
    cnt++;
    marked[node] = 1;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m, i, a, b, k;
  cin >> n;
  for (i = 0; i < n; i++) cin >> v[i];
  for (i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    g[u - 1].push_back(v - 1);
    g[v - 1].push_back(u - 1);
  }
  S = dfs(0, 0);
  getcnt(0, 0);
  cout << S * cnt << ' ' << cnt << '\n';
  return 0;
}
