#include <bits/stdc++.h>
using namespace std;
int n, a[300002];
vector<int> adj[300002];
long long dp[300002];
long long ansx;
int ansy;
void dfs(int nod, int par, bool sol) {
  dp[nod] = a[nod];
  for (int son : adj[nod])
    if (son != par) {
      dfs(son, nod, sol);
      if (dp[son] >= 0) dp[nod] += dp[son];
    }
  if (sol && dp[nod] == ansx) {
    ++ansy;
    dp[nod] = 0;
  } else
    ansx = max(ansx, dp[nod]);
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  ansx = a[0] - 1;
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    --u;
    --v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(0, -1, 0);
  dfs(0, -1, 1);
  printf("%lld %d\n", 1LL * ansx * ansy, ansy);
  return 0;
}
