#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 3e5 + 5;
const long long mod = 1e9 + 7;
template <typename _tp>
inline _tp read(_tp& x) {
  char ch = getchar(), sgn = 0;
  x = 0;
  while (ch ^ '-' && !isdigit(ch)) ch = getchar();
  if (ch == '-') ch = getchar(), sgn = 1;
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  if (sgn) x = -x;
  return x;
}
long long n;
long long a[MAXN];
long long dp[MAXN];
long long par[MAXN];
long long vis[MAXN];
vector<long long> g[MAXN];
long long maxi = LLONG_MIN, cnt;
void dfs(long long u, long long p, long long flag) {
  par[u] = p;
  dp[u] = a[u];
  for (long long v : g[u]) {
    if (v == p) continue;
    dfs(v, u, flag);
    if (dp[v] > 0) dp[u] += dp[v];
  }
  if (!flag)
    maxi = max(maxi, dp[u]);
  else if (maxi == dp[u])
    cnt++, dp[u] = 0;
}
signed main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  read(n);
  for (long long i = 1; i <= n; i++) {
    read(a[i]);
  }
  for (long long i = 1; i <= n - 1; i++) {
    long long u, v;
    read(u), read(v);
    g[u].push_back(v), g[v].push_back(u);
  }
  dfs(1, 0, 0);
  dfs(1, 0, 1);
  cout << cnt * maxi << " " << cnt << endl;
  return 0;
}
