#include <bits/stdc++.h>
int N;
int Weight[300005];
long long SubWeight[300005];
std::vector<int> ADC[300005];
inline void AddEdge(int x, int y) {
  ADC[x].push_back(y);
  ADC[y].push_back(x);
}
long long Max;
int Count;
void DFS(bool Step, int Node = 1, int Parent = 0) {
  SubWeight[Node] = Weight[Node];
  for (auto Vecin : ADC[Node])
    if (Vecin != Parent) {
      DFS(Step, Vecin, Node);
      SubWeight[Node] += std::max(SubWeight[Vecin], 0LL);
    }
  if (Step)
    Max = std::max(Max, SubWeight[Node]);
  else if (SubWeight[Node] == Max)
    ++Count, SubWeight[Node] = 0;
}
void Citire() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) scanf("%d", &Weight[i]);
  for (int i = 1, x, y; i < N; ++i) scanf("%d%d", &x, &y), AddEdge(x, y);
}
void Rezolvare() {
  Max = -1000000005;
  DFS(1);
  DFS(0);
  printf("%I64d %d", Count * Max, Count);
}
int main() {
  Citire();
  Rezolvare();
  return 0;
}
