An integer \(N\) (1 ≤ \(N\) ≤ 5000), representing some quantity or size.
A list of \(N\) integers, where each integer is between -10^9 and 10^9.
A list of \(N-1\) pairs of integers, where each integer is between 1 and \(N\).

### Example Input:

```
7
-2 7 5 6 -8 3 4
1 2
2 3
2 4
1 5
5 6
5 7
```

### Function Signature:
Write a function f(N, A, connections) that takes in the input. 
def f(N: int, A: List[int], connections: List[Tuple[int, int]]): 
    ''' 
    N: an integer 
    A: a list of integers
    connections: a list of tuples
    '''