#include <bits/stdc++.h>
using namespace std;
int n, i, k, u, v, cnt;
int head[300005], a[300005];
long long f[300005], ans;
struct ff {
  int to, nxt;
} e[2 * 300005];
int fast() {
  int res = 0, fl = 1;
  char c = getchar();
  while (c < 48 || c > 57) {
    if (c == '-') fl = -1;
    c = getchar();
  }
  while (c >= 48 && c <= 57) res = res * 10 + c - 48, c = getchar();
  return res * fl;
}
void write(long long x) {
  if (x > 9) write(x / 10);
  putchar(x % 10 + 48);
}
void add(int u, int v) {
  e[++cnt] = (ff){v, head[u]};
  head[u] = cnt;
}
void dfs(int now, int fa, int fl) {
  f[now] = a[now];
  for (int i = head[now]; i; i = e[i].nxt) {
    int v = e[i].to;
    if (v == fa) continue;
    dfs(v, now, fl);
    if (f[v] > 0) f[now] += f[v];
  }
  if (fl)
    ans = max(ans, f[now]);
  else if (ans == f[now])
    k++, f[now] = -1;
}
int main() {
  n = fast();
  for (i = 1; i <= n; i++) a[i] = fast();
  for (i = 1; i < n; i++) {
    u = fast(), v = fast();
    add(u, v), add(v, u);
  }
  ans = -(long long)1e16;
  dfs(1, 0, 1);
  dfs(1, 0, 0);
  printf("%lld %d\n", ans * k, k);
  return 0;
}
