#include <bits/stdc++.h>
using namespace std;
const int N = 3 * 1e5 + 10;
vector<int> adj[N];
long long pt[N], f[N];
long long M = -1e18, cnt;
void dfs(int u, int pr) {
  f[u] = pt[u];
  for (auto v : adj[u]) {
    if (v != pr) {
      dfs(v, u);
      f[u] += max(0LL, f[v]);
    }
  }
}
long long update_dfs(int u, int pr) {
  long long sum = pt[u];
  for (int v : adj[u]) {
    if (v != pr) {
      sum += update_dfs(v, u);
    }
  }
  if (sum == M) {
    cnt++;
    return 0;
  }
  return max(0LL, sum);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> pt[i];
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  dfs(1, 0);
  for (int i = 1; i <= n; i++) M = max(f[i], M);
  update_dfs(1, 0);
  cout << M * cnt << " " << cnt << "\n";
  return 0;
}
