#include <bits/stdc++.h>
using namespace std;
int N;
int A[300005];
long long DP[300005], res;
int Max = -1000000005, cntMax = 0;
vector<int> G[300005];
void Read() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &A[i]);
    if (A[i] == Max) ++cntMax;
    if (A[i] > Max) {
      Max = A[i];
      cntMax = 1;
    }
  }
  for (int i = 1; i < N; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    G[x].push_back(y);
    G[y].push_back(x);
  }
}
void DFS(int node, int father) {
  DP[node] = A[node];
  for (int i = 0; i < G[node].size(); i++) {
    int neighb = G[node][i];
    if (neighb == father) continue;
    DFS(neighb, node);
    DP[node] += max(0LL, DP[neighb]);
  }
}
void DFS2(int node, int father) {
  DP[node] = A[node];
  for (int i = 0; i < G[node].size(); i++) {
    int neighb = G[node][i];
    if (neighb == father) continue;
    DFS2(neighb, node);
    DP[node] += max(0LL, DP[neighb]) < res ? max(0LL, DP[neighb]) : 0;
  }
}
void precalcRes() {
  for (int i = 1; i <= N; i++) res = max(res, DP[i]);
}
void Solve() {
  long long Max = -1000000000000000005, cnt = 0;
  for (int i = 1; i <= N; i++) {
    if (DP[i] == Max) ++cnt;
    if (DP[i] > Max) {
      Max = DP[i];
      cnt = 1;
    }
  }
  printf("%I64d %I64d\n", Max * cnt, cnt);
}
int main() {
  Read();
  if (Max <= 0) {
    printf("%I64d %d\n", 1LL * cntMax * Max, cntMax);
    return 0;
  }
  DFS(1, 0);
  precalcRes();
  DFS2(1, 0);
  Solve();
  return 0;
}
