#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
const int inf = -0x3f3f3f3f;
vector<int> G[maxn];
int a[maxn];
int n, k;
long long ans = inf, d[maxn];
void dfs_1(int u, int fa) {
  d[u] = a[u];
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (v == fa) continue;
    dfs_1(v, u);
    d[u] = max(d[u], d[u] + d[v]);
  }
  ans = max(ans, (long long)d[u]);
}
void dfs_2(int u, int fa) {
  d[u] = a[u];
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (v == fa) continue;
    dfs_2(v, u);
    d[u] = max(d[u], d[u] + d[v]);
  }
  if (d[u] == ans) d[u] = inf, k++;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs_1(1, -1);
  dfs_2(1, -1);
  printf("%lld %d\n", ans * k, k);
}
