#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9')
    s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
  return s * w;
}
struct edge {
  int v, nxt;
} e[300010 << 1];
int n, cnt, head[300010];
long long val[300010];
void add(int u, int v) {
  e[++cnt].v = v;
  e[cnt].nxt = head[u];
  head[u] = cnt;
}
long long f[300010], ans = -1e16, num;
void dfs(int u, int fa) {
  f[u] = val[u];
  for (int i = head[u]; i != 0; i = e[i].nxt)
    if (e[i].v != fa) {
      dfs(e[i].v, u);
      if (f[e[i].v] > 0) f[u] += f[e[i].v];
    }
  ans = max(ans, f[u]);
}
void dfs2(int u, int fa) {
  f[u] = val[u];
  for (int i = head[u]; i != 0; i = e[i].nxt)
    if (e[i].v != fa) {
      dfs2(e[i].v, u);
      if (f[e[i].v] > 0) f[u] += f[e[i].v];
    }
  if (f[u] == ans) num++, f[u] = 0;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) f[i] = -1e16;
  for (int i = 1; i <= n; i++) val[i] = read();
  for (int i = 1; i < n; i++) {
    int u = read(), v = read();
    add(u, v);
    add(v, u);
  }
  dfs(1, 0);
  for (int i = 1; i <= n; i++) f[i] = -1e16;
  dfs2(1, 0);
  printf("%lld %lld", ans * num, num);
  return 0;
}
