#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
long long mx = -1e18, mn[N];
bool vis[N];
int ans, a[N];
vector<int> adj[N];
long long dfs(int x) {
  if (vis[x]) return 0;
  vis[x] = 1;
  long long S = 0, s = a[x];
  for (int i = 0; i < adj[x].size(); i++) {
    s += dfs(adj[x][i]);
    S += mn[adj[x][i]];
  }
  mx = max(mx, s - S);
  mn[x] = min(S, s);
  return s;
}
long long dfs0(int x) {
  if (vis[x]) return 0;
  vis[x] = 1;
  long long S = 0, s = a[x];
  mn[x] = 0;
  for (int i = 0; i < adj[x].size(); i++) {
    s += dfs0(adj[x][i]);
    S += mn[adj[x][i]];
  }
  if (s - S == mx) {
    ans++;
    mn[x] = 0;
    return 0;
  }
  mn[x] = min(S, s);
  return s;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  dfs(1);
  memset(vis, 0, sizeof vis);
  dfs0(1);
  printf("%I64d %d", mx * ans, ans);
  return 0;
}
