#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 300005;
vector<int> v[MAX_N];
long long dp[MAX_N], a[MAX_N], o;
int br;
void dfs(int x, int p, bool l) {
  int i, n = v[x].size();
  dp[x] = a[x];
  for (i = 0; i < n; i++)
    if (v[x][i] != p) {
      dfs(v[x][i], x, l);
      dp[x] += max(dp[v[x][i]], 0ll);
    }
  if (l)
    o = max(dp[x], o);
  else if (dp[x] == o) {
    br++;
    dp[x] = 0;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, i, x, y;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  o = a[1];
  for (i = 1; i < n; i++) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs(1, 0, 1);
  dfs(1, 0, 0);
  cout << o * br << " " << br << '\n';
}
