#include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
namespace debug {
void err() { cout << "" << endl; }
template <template <typename...> class T, typename t, typename... Args>
void err(T<t> a, Args... args) {
  for (auto x : a) cout << x << ' ';
  err(args...);
}
template <typename T, typename... Args>
void err(T a, Args... args) {
  cout << a << ' ';
  err(args...);
}
}  // namespace debug
namespace stdio_input {
void scanf_int() {}
template <typename T, typename... Args>
void scanf_int(T &a, Args &...args) {
  scanf("%d", &a);
  scanf_int(args...);
}
void scanf_ll() {}
template <typename T, typename... Args>
void scanf_ll(T &a, Args &...args) {
  scanf("%lld", &a);
  scanf_ll(args...);
}
void scanf_double() {}
template <typename T, typename... Args>
void scanf_double(T &a, Args &...args) {
  scanf("%lf", &a);
  scanf_double(args...);
}
}  // namespace stdio_input
namespace const_var {
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const double PI = acos(-1.0);
const long double eps = 1e-20;
const int N = 1e6 + 10;
}  // namespace const_var
using namespace debug;
using namespace stdio_input;
using namespace const_var;
int T = 0;
void testcase() { cout << "Case #" << (++T) << ": "; }
int a[N];
long long dp[N];
vector<int> G[N];
void dfs(int u, int fa) {
  dp[u] = a[u];
  for (auto &v : G[u]) {
    if (v == fa) continue;
    dfs(v, u);
    if (dp[v] >= 0) {
      dp[u] += dp[v];
    }
  }
}
int cnt = 0;
void dfs1(int u, int fa, long long ans) {
  dp[u] = a[u];
  for (auto &v : G[u]) {
    if (v == fa) continue;
    dfs1(v, u, ans);
    if (dp[v] >= 0) {
      dp[u] += dp[v];
    }
  }
  if (dp[u] == ans) {
    ++cnt;
    dp[u] = 0;
  }
}
inline void work() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    cin >> u >> v;
    G[u].emplace_back(v);
    G[v].emplace_back(u);
  }
  dfs(1, 1);
  long long ans = -INF;
  for (int i = 1; i <= n; ++i) {
    ans = max(ans, dp[i]);
  }
  dfs1(1, 1, ans);
  cout << ans * cnt << " " << cnt << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  work();
  return 0;
}
