#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 7, MAXM = 1e6 + 7, MAXK = 1e6 + 7;
long long a[MAXN], b[MAXN], ans;
int father[MAXN], num;
vector<int> p[MAXN];
void dfs(int x, int fa) {
  int len = p[x].size();
  father[x] = fa;
  for (int i = 0; i < len; i++) {
    if (p[x][i] != fa) {
      dfs(p[x][i], x);
      a[x] += max(a[p[x][i]], 0LL);
    }
  }
}
void dfs0(int x, int fa) {
  int len = p[x].size();
  for (int i = 0; i < len; i++) {
    if (p[x][i] != fa) {
      dfs0(p[x][i], x);
      b[x] += max(b[p[x][i]], 0LL);
    }
  }
  if (b[x] == ans) {
    num++;
    b[x] = 0;
  }
}
int main() {
  int n, u, v;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &a[i]), b[i] = a[i];
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &u, &v);
    p[u].push_back(v);
    p[v].push_back(u);
  }
  dfs(1, 0);
  ans = -1e9;
  for (int i = 1; i <= n; i++) ans = max(ans, a[i]);
  num = 0;
  dfs0(1, 0);
  printf("%lld %d", ans * num, num);
  return 0;
}
