#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 50;
vector<long long> v[MAXN];
long long a[MAXN];
long long dp[MAXN];
long long ans = -1e18;
long long k = 0;
void dfs(long long now, long long pre) {
  long long l = v[now].size();
  dp[now] = a[now];
  ans = max(ans, dp[now]);
  for (long long i = 0; i < l; i++) {
    long long to = v[now][i];
    if (to == pre) continue;
    dfs(to, now);
    if (dp[to] > 0) dp[now] += dp[to];
    ans = max(ans, dp[now]);
  }
}
long long dfs1(long long now, long long pre) {
  long long l = v[now].size();
  long long sum = a[now];
  for (long long i = 0; i < l; i++) {
    long long to = v[now][i];
    if (to == pre) continue;
    long long w = dfs1(to, now);
    if (w > 0) sum += w;
  }
  if (sum == ans) {
    k++;
    sum = 0;
  }
  return sum;
}
int main() {
  ios::sync_with_stdio(false);
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (long long i = 1; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs(1, 0);
  dfs1(1, 0);
  cout << ans * k << ' ' << k << endl;
}
