#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 505;
const long long MAXM = 1e5 + 1;
const long long INF = 1e9 + 1;
const long long MOD = 998244353;
const long double EPS = 1e-12;
const long double PI = acos(-1);
const unsigned long long PRIME = 31;
void bye() {
  cout << "\n";
  exit(0);
}
long long n;
vector<long long> a;
vector<vector<long long> > g;
vector<long long> dp;
long long ans = -INF, k = 0;
void dfs(long long v, long long p) {
  dp[v] = a[v];
  for (auto to : g[v]) {
    if (to != p) {
      dfs(to, v);
      dp[v] += max(dp[to], 0LL);
    }
  }
  ans = max(ans, dp[v]);
}
void dfs1(long long v, long long p) {
  dp[v] = a[v];
  for (auto to : g[v]) {
    if (to != p) {
      dfs1(to, v);
      dp[v] += max(dp[to], 0LL);
    }
  }
  if (dp[v] == ans) {
    k++;
    dp[v] = 0;
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  g.resize(n);
  a.resize(n);
  dp.resize(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long i = 1; i < n; i++) {
    long long u, v;
    cin >> u >> v;
    u--, v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(0, -1);
  dfs1(0, -1);
  cout << ans * k << " " << k;
  bye();
}
