#include <bits/stdc++.h>
using namespace std;
const int N = 300010;
long long a[N], b[N], c[N], mx;
vector<int> v[N];
void dfs(int x, int p = 0) {
  b[x] = a[x];
  for (int y : v[x]) {
    if (y == p) continue;
    dfs(y, x);
    if (b[y] > 0) b[x] += b[y];
  }
}
int dfs2(int x, int p = 0) {
  c[x] = a[x];
  int r = 0;
  for (int y : v[x]) {
    if (y == p) continue;
    r += dfs2(y, x);
    if (c[y] > 0) {
      c[x] += c[y];
    }
  }
  if (c[x] == mx) {
    r++;
    c[x] = 0;
  }
  return r;
}
int main() {
  ios::sync_with_stdio(false);
  ;
  int n, x, y;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i < n; i++) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs(1);
  mx = -1e18;
  for (int i = 1; i <= n; i++) mx = max(mx, b[i]);
  long long k = dfs2(1);
  cout << mx * k << " " << k << "\n";
  return 0;
}
