#include <bits/stdc++.h>
using namespace std;
const int N = 1100000;
int mod = 998244353;
int a[1000010];
int n;
vector<int> g[1000010];
long long ans;
int k;
long long dfs1(int t, int f) {
  long long res = a[t];
  for (int x : g[t]) {
    if (x == f) continue;
    res += max(0ll, dfs1(x, t));
  }
  ans = max(ans, res);
  return res;
}
long long dfs2(int t, int f) {
  long long res = a[t];
  for (int x : g[t]) {
    if (x == f) continue;
    res += max(0ll, dfs2(x, t));
  }
  if (res == ans) {
    k++;
    return 0;
  }
  return res;
}
int main() {
  cin >> n;
  for (int i = 1; i < n + 1; ++i) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  ans = -1e16;
  dfs1(1, 1);
  k = 0;
  dfs2(1, 1);
  cout << ans * k << " " << k << endl;
}
