#include <bits/stdc++.h>
using namespace std;
const int N = 300010;
int n, arr[N], u, v;
vector<int> g[N];
long long mx = -(long long)1e18, b = 0, dp[N];
void DFS(int node, int prnt) {
  dp[node] = arr[node];
  for (int i = 0; i < (int)g[node].size(); i++) {
    if (g[node][i] == prnt) continue;
    DFS(g[node][i], node);
    if (dp[g[node][i]] >= 0) dp[node] += dp[g[node][i]];
  }
  mx = max(mx, dp[node]);
}
void DFS2(int node, int prnt) {
  dp[node] = arr[node];
  for (int i = 0; i < (int)g[node].size(); i++) {
    if (g[node][i] == prnt) continue;
    DFS2(g[node][i], node);
    if (dp[g[node][i]] >= 0) dp[node] += dp[g[node][i]];
  }
  if (dp[node] == mx) {
    dp[node] = 0;
    b++;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &arr[i]);
  for (int i = 0; i < n - 1; i++) {
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  DFS(1, -1);
  DFS2(1, -1);
  cout << mx * b << " " << b << endl;
  return 0;
}
