#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
const long long inf = 1e15;
int n;
long long a[N];
bool was[N];
long long f[N];
long long maxf;
vector<int> g[N];
void dfs(int u, int p) {
  f[u] = a[u];
  for (int v : g[u]) {
    if (v == p) continue;
    dfs(v, u);
    if (f[v] > 0) {
      f[u] += f[v];
    }
  }
}
int ret = 0;
bool mark[N];
void redfs(int u, int p) {
  f[u] = a[u];
  for (int v : g[u]) {
    if (v == p) continue;
    redfs(v, u);
    if (f[v] > 0 && not mark[v]) {
      f[u] += f[v];
    }
  }
  if (f[u] == maxf) {
    mark[u] = 1;
    ret++;
  }
}
int main() {
  ios ::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(1, -1);
  maxf = -inf;
  for (int i = 1; i <= n; i++) {
    maxf = max(maxf, f[i]);
  }
  redfs(1, -1);
  cout << maxf * ret << " " << ret << endl;
}
