#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
inline long long rd() {
  long long x = 0, neg = 1;
  ;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') neg = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + c - '0', c = getchar();
  return neg * x;
}
int N, a[maxn], eg[maxn * 2][2], egh[maxn], ect;
long long f[maxn], answ = -1e15, ansk;
inline void adeg(int a, int b) {
  eg[++ect][0] = b, eg[ect][1] = egh[a], egh[a] = ect;
}
inline void dfs(int x, int fa, int p) {
  f[x] = a[x];
  for (int i = egh[x]; i; i = eg[i][1]) {
    int b = eg[i][0];
    if (b == fa) continue;
    dfs(b, x, p);
    if (f[b] > 0) f[x] += f[b];
  }
  if (p == 1)
    answ = max(answ, f[x]);
  else {
    if (f[x] == answ) ansk++, f[x] = -1e15;
  }
}
int main() {
  int i, j, k, x, y;
  N = rd();
  for (i = 1; i <= N; i++) a[i] = rd();
  for (i = 1; i < N; i++) x = rd(), y = rd(), adeg(x, y), adeg(y, x);
  dfs(1, 0, 1);
  dfs(1, 0, 0);
  answ *= ansk;
  printf("%I64d %I64d\n", answ, ansk);
  return 0;
}
