#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10, INF = 1e9;
vector<int> adj[N];
int a[N], cant = 0;
long long mx = -INF;
bool in[N];
long long dfs1(int u, int p = -1) {
  long long sum = a[u];
  for (int v : adj[u])
    if (v != p) sum += max(0LL, dfs1(v, u));
  mx = max(mx, sum);
  return sum;
}
long long dfs2(int u, int p = -1) {
  long long sum = a[u];
  for (int v : adj[u])
    if (v != p) sum += max(0LL, dfs2(v, u));
  if (sum == mx) cant++, sum = 0;
  return sum;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int u = int(0); u < int(n); u++) cin >> a[u];
  for (int _ = int(0); _ < int(n - 1); _++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    adj[u].emplace_back(v);
    adj[v].emplace_back(u);
  }
  dfs1(0);
  dfs2(0);
  cout << mx * cant << ' ' << cant << '\n';
  return 0;
}
