#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
template <class T>
inline bool MX(T &l, const T &r) {
  return l < r ? l = r, 1 : 0;
}
template <class T>
inline bool MN(T &l, const T &r) {
  return l > r ? l = r, 1 : 0;
}
const long long INF = 1LL << 41;
int N;
long long t;
long long A[314514];
bool used[314514];
vector<int> es[314514];
long long Dfs(int v, int p) {
  long long ret = 0;
  long long tot = A[v];
  for (int u : es[v]) {
    if (u == p) continue;
    tot += max(Dfs(u, v), 0LL);
  }
  MX(t, tot);
  return tot;
}
long long Dfs2(int v, long long &opt) {
  used[v] = true;
  long long tot = A[v];
  for (int u : es[v]) {
    if (used[u]) continue;
    tot += max(Dfs2(u, opt), 0LL);
  }
  if (tot == t) {
    opt++;
    return 0;
  }
  return tot;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(0);
  bool all_neg = true;
  cin >> N;
  long long maxi = -INF;
  for (int(i) = 0; (i) < (N); ++(i)) {
    cin >> A[i];
    all_neg &= (A[i] <= 0);
    MX(maxi, A[i]);
  }
  for (int(i) = 0; (i) < (N - 1); ++(i)) {
    int u, v;
    cin >> u >> v;
    --u;
    --v;
    es[u].emplace_back(v);
    es[v].emplace_back(u);
  }
  if (all_neg) {
    int cnt = 0;
    for (int(i) = 0; (i) < (N); ++(i)) {
      if (A[i] == maxi) cnt++;
    }
    assert(cnt > 0);
    cout << maxi * cnt << " " << cnt << endl;
    return 0;
  }
  t = -INF;
  Dfs(0, 0);
  long long cnt = 0;
  Dfs2(0, cnt);
  cout << t * cnt << " " << cnt << endl;
}
