#include <bits/stdc++.h>
using namespace std;
const int MaxN = 300000 + 5;
const long long INF = 0x7F7F7F7F7F7F7F7F;
int N, K;
long long Ans = -INF;
long long A[MaxN], dp[MaxN];
vector<int> G[MaxN];
void init() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) scanf("%lld", &A[i]);
  for (int i = 1; i < N; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
}
void dfs1(int u, int f) {
  dp[u] = A[u];
  for (auto v : G[u]) {
    if (v == f) continue;
    dfs1(v, u);
    dp[u] += max(dp[v], 0ll);
  }
  Ans = max(Ans, dp[u]);
}
void dfs2(int u, int f) {
  dp[u] = A[u];
  for (auto v : G[u]) {
    if (v == f) continue;
    dfs2(v, u);
    dp[u] += max(dp[v], 0ll);
  }
  if (dp[u] == Ans) {
    dp[u] = 0;
    K++;
  }
}
void solve() {
  dfs1(1, 0);
  dfs2(1, 0);
  cout << Ans * K << " " << K << endl;
}
int main() {
  init();
  solve();
  return 0;
}
