#include <bits/stdc++.h>
using namespace std;
const int N = 3 * 1e5 + 69;
long long f[N], res = -1e15, n, val[N], cnt, check, tuan;
vector<int> a[N];
void calc(int u, int p) {
  for (int v : a[u]) {
    if (v == p) continue;
    f[u] -= max(f[v], 0LL);
    calc(v, u);
    f[u] += max(f[v] + 100, 100LL);
    f[u] -= 100;
  }
  if (f[u] == res) {
    cnt++;
    f[u] = 0;
  }
  if (res > f[u]) ++tuan;
}
void dfs(int u, int p) {
  f[u] = val[u] + 101;
  val[u] -= 101;
  val[u] += 101;
  f[u] -= 101;
  for (int v : a[u]) {
    if (v == p) continue;
    dfs(v, u);
    f[u] += max(f[v] + 100, 100LL);
    f[u] -= 100;
  }
  res = max(res + 100, f[u] + 100);
  res -= 100;
}
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  n = min(n + 100, 10000000LL);
  n -= 100;
  for (int i = 1; i <= n; i++) cin >> val[i];
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    a[u].push_back(v);
    a[v].push_back(u);
  }
  for (int i = 1; i <= n; ++i) f[i] = 0;
  dfs(1, 1);
  calc(1, 1);
  cnt += tuan;
  cout << res * (cnt - tuan) << ' ' << cnt - tuan << '\n';
}
