#include <bits/stdc++.h>
bool debug = 0;
const long long MOD = 1000000007;
const double PI = acos(-1.0);
const double eps = 1e-9;
using namespace std;
long long dp1[300100], dp2[300100];
long long a[300100], ans = -10000000000LL;
int n;
vector<int> adj[300100];
void dfs1(int u, int pai) {
  long long sum = a[u];
  for (int v : adj[u]) {
    if (v != pai) {
      dfs1(v, u);
      sum += dp1[v] > 0 ? dp1[v] : 0;
    }
  }
  dp1[u] = sum;
}
int dfs2(int u, int pai) {
  long long sum = a[u];
  int k = 0;
  for (int v : adj[u]) {
    if (v != pai) {
      k += dfs2(v, u);
      sum += dp2[v] > 0 ? dp2[v] : 0;
    }
  }
  if (sum == ans) {
    dp2[u] = 0;
    k++;
  } else
    dp2[u] = sum;
  return k;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
  }
  int x, y;
  for (int i = 0; i < n - 1; i++) {
    scanf("%d %d", &x, &y);
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  dfs1(1, 0);
  for (int i = 1; i <= n; i++) {
    ans = max(ans, dp1[i]);
  }
  if (debug)
    cout << "ans"
         << " = " << (ans) << endl;
  int k = 0;
  if (ans <= 0) {
    for (int i = 1; i <= n; i++) {
      if (a[i] == ans) k++;
    }
  } else {
    k = dfs2(1, 0);
  }
  printf("%lld %d\n", ans * k, k);
  return 0;
}
