#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, long long int y) {
  long long int res = 1;
  while (y) {
    if (y & 1) res = (res * x) % 1000000007;
    y = y / 2, x = (x * x) % 1000000007;
  }
  return res % 1000000007;
}
long long int child[1000000];
long long int val[1000000];
vector<vector<long long int> > arr(1000000);
long long int cnt = 0;
long long int ma = -1e18;
void dfs(long long int u, long long int par) {
  child[u] = val[u];
  long long int i;
  for (i = 0; i < arr[u].size(); i++) {
    long long int v = arr[u][i];
    if (v != par) {
      dfs(v, u);
      if (child[v] > 0) child[u] += child[v];
    }
  }
}
void dfs1(long long int u, long long int par) {
  long long int i;
  child[u] = val[u];
  for (i = 0; i < arr[u].size(); i++) {
    long long int v = arr[u][i];
    if (v != par) {
      dfs1(v, u);
      if (child[v] > 0) child[u] += child[v];
    }
  }
  if (child[u] == ma) {
    child[u] = 0;
    cnt++;
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  long long int i;
  for (i = 1; i <= n; i++) cin >> val[i];
  for (i = 0; i < n - 1; i++) {
    long long int u, v;
    cin >> u >> v;
    arr[u].push_back(v);
    arr[v].push_back(u);
  }
  dfs(1, 0);
  for (i = 1; i <= n; i++) {
    ma = max(ma, child[i]);
  }
  dfs1(1, 0);
  cout << ma * cnt << " " << cnt;
}
