#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int N = 3e5 + 100;
vector<int> node[N];
int val[N];
long long dp[N];
long long mmax, ans;
void dfs1(int u, int fa) {
  dp[u] = val[u];
  for (int i = 0; i < node[u].size(); i++) {
    int v = node[u][i];
    if (v == fa) continue;
    dfs1(v, u);
    dp[u] += max(dp[v], 0LL);
  }
  mmax = max(mmax, dp[u]);
}
void dfs2(int u, int fa) {
  dp[u] = val[u];
  for (int i = 0; i < node[u].size(); i++) {
    int v = node[u][i];
    if (v == fa) continue;
    dfs2(v, u);
    dp[u] += max(dp[v], 0LL);
  }
  if (dp[u] == mmax) {
    ans++;
    dp[u] = -inf;
  }
}
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    for (int i = 1; i <= n; i++) {
      scanf("%d", val + i);
      node[i].clear();
    }
    for (int i = 1; i < n; i++) {
      int u, v;
      scanf("%d%d", &u, &v);
      node[u].push_back(v);
      node[v].push_back(u);
    }
    mmax = -inf;
    ans = 0;
    dfs1(1, -1);
    dfs2(1, -1);
    cout << mmax * ans << ' ' << ans << endl;
  }
  return 0;
}
