You're given a tree consisting of n nodes. Every node u has a weight a_u. You want to choose an integer k (1 ≤ k ≤ n) and then choose k connected components of nodes that don't overlap (i.e every node is in at most 1 component). Let the set of nodes you chose be s. You want to maximize:

$$$\frac{∑_{u ∈ s} a_u}{k}$$$

In other words, you want to maximize the sum of weights of nodes in s divided by the number of connected components you chose. Also, if there are several solutions, you want to maximize k.

Note that adjacent nodes can belong to different components. Refer to the third sample.

Input

The first line contains the integer n (1 ≤ n ≤ 3 ⋅ 10^5), the number of nodes in the tree.

The second line contains n space-separated integers a_1, a_2, ..., a_n (|a_i| ≤ 10^9), the weights of the nodes.

The next n-1 lines, each contains 2 space-separated integers u and v (1 ≤ u,v ≤ n) which means there's an edge between u and v.

Output

Print the answer as a non-reduced fraction represented by 2 space-separated integers. The fraction itself should be maximized and if there are several possible ways, you should maximize the denominator. See the samples for a better understanding.

Examples

Input


3
1 2 3
1 2
1 3


Output


6 1

Input


1
-2


Output


-2 1

Input


3
-1 -1 -1
1 2
2 3


Output


-3 3

Input


3
-1 -2 -1
1 2
1 3


Output


-2 2

Note

A connected component is a set of nodes such that for any node in the set, you can reach all other nodes in the set passing only nodes in the set.

In the first sample, it's optimal to choose the whole tree.

In the second sample, you only have one choice (to choose node 1) because you can't choose 0 components.

In the third sample, notice that we could've, for example, chosen only node 1, or node 1 and node 3, or even the whole tree, and the fraction would've had the same value (-1), but we want to maximize k. 

In the fourth sample, we'll just choose nodes 1 and 3.
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
vector<int> G[maxn];
int a[maxn];
long long mx = -1e18, cnt, dp[maxn];
void dfs(int v, int fa, int flag) {
  dp[v] = a[v];
  for (int i = G[v].size() - 1; i >= 0; i--) {
    int to = G[v][i];
    if (to == fa) continue;
    dfs(to, v, flag);
    if (dp[to] > 0) dp[v] += dp[to];
  }
  if (!flag)
    mx = max(mx, dp[v]);
  else if (dp[v] == mx)
    cnt++, dp[v] = 0;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    G[x].push_back(y);
    G[y].push_back(x);
  }
  dfs(1, 0, 0);
  dfs(1, 0, 1);
  printf("%lld %lld\n", cnt * mx, cnt);
  return 0;
}
