#include <bits/stdc++.h>
using namespace std;
inline char nc() {
  static char *p1, *p2, buf[100000];
  return (p1 == p2) &&
                 (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
int rd() {
  int x = 0, f = 1;
  char c = nc();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = nc();
  }
  while (isdigit(c)) x = (x << 3) + (x << 1) + (c ^ 48), c = nc();
  return x * f;
}
int head[300010], tot, a[300010], nxt[300010 << 1], to[300010 << 1], n;
long long dp[300010], ans1 = -0x3f3f3f3f3f3f3f3fll, ans2;
inline void add(int x, int y) {
  to[++tot] = y;
  nxt[tot] = head[x];
  head[x] = tot;
}
void dfs1(int x, int fa) {
  dp[x] = a[x];
  for (int i = head[x]; i; i = nxt[i])
    if (to[i] != fa) {
      dfs1(to[i], x), dp[x] += max(dp[to[i]], 0ll);
    }
  ans1 = max(ans1, dp[x]);
}
void dfs2(int x, int fa) {
  dp[x] = a[x];
  for (int i = head[x]; i; i = nxt[i])
    if (to[i] != fa) {
      dfs2(to[i], x), dp[x] += max(dp[to[i]], 0ll);
    }
  if (dp[x] == ans1) ans2++, dp[x] = 0;
}
int main() {
  n = rd();
  for (int i = 1; i <= n; i++) a[i] = rd();
  for (int i = 1, x, y; i < n; i++) x = rd(), y = rd(), add(x, y), add(y, x);
  dfs1(1, 0);
  dfs2(1, 0);
  printf("%lld %lld\n", ans1 * ans2, ans2);
}
