#include <bits/stdc++.h>
using namespace std;
vector<vector<long long> > G;
vector<long long> w;
vector<long long> A;
bitset<300010> used;
long long MAX = 0;
void rec(long long v) {
  used[v] = 1;
  A[v] = w[v];
  for (long long to : G[v]) {
    if (used[to]) continue;
    rec(to);
    if (A[to] > 0) A[v] += A[to];
  }
}
void rec2(long long v) {
  used[v] = 1;
  A[v] = w[v];
  for (long long to : G[v]) {
    if (used[to]) continue;
    rec2(to);
    if (A[to] > 0 && A[to] < MAX) A[v] += A[to];
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  long long n;
  cin >> n;
  G.resize(n);
  w.resize(n);
  A.resize(n);
  long long M = -1;
  for (long long i = 0; i < n; i++) {
    cin >> w[i];
    M = max(w[i], M);
  }
  for (long long i = 1, a, b; i < n; i++) {
    cin >> a >> b;
    --a;
    --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  if (M == -1) {
    sort(w.begin(), w.end());
    reverse(w.begin(), w.end());
    long long huh1 = -9999999999999, huh2 = 1;
    long long sum = 0;
    for (long long i = 0; i < n; i++) {
      sum += w[i];
      if (huh1 * (i + 1) <= sum * huh2) {
        huh1 = sum, huh2 = i + 1;
      }
    }
    cout << huh1 << " " << huh2;
    return 0;
  }
  rec(0);
  M = 0;
  for (long long i = 0; i < n; i++) {
    M = max(M, A[i]);
  }
  MAX = M;
  used.reset();
  rec2(0);
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (A[i] == MAX) cnt++;
  }
  cout << MAX * cnt << " " << cnt;
  return 0;
}
