#include <bits/stdc++.h>
using namespace std;
int n, a[300005], u, v, cnt, head[300005], num;
bool used[300005];
long long F[300005], ans;
struct node {
  int to, next;
} e[300005 << 1];
void insert(int u, int v) {
  e[++cnt].to = v;
  e[cnt].next = head[u];
  head[u] = cnt;
  e[++cnt].to = u;
  e[cnt].next = head[v];
  head[v] = cnt;
}
void dfs(int x, int fa) {
  F[x] = a[x];
  for (int i = head[x]; i; i = e[i].next)
    if (e[i].to ^ fa) {
      dfs(e[i].to, x);
      if (F[e[i].to] >= 0) F[x] += F[e[i].to];
    }
  ans = max(ans, F[x]);
}
void solve(int x, int fa) {
  F[x] = a[x];
  for (int i = head[x]; i; i = e[i].next)
    if (e[i].to ^ fa) {
      solve(e[i].to, x);
      if (!used[e[i].to] && F[e[i].to] >= 0) F[x] += F[e[i].to];
    }
  if (F[x] == ans) used[x] = 1, num++;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i < n; i++) scanf("%d%d", &u, &v), insert(u, v);
  ans = -1e9;
  dfs(1, 0);
  solve(1, 0);
  cout << ans * num << " " << num << endl;
  return 0;
}
